class RubyAemAws::AemAws
AemAws
class represents the AWS stack for AEM.
Public Class Methods
@param conf configuration hash of the following configuration values:
-
region: the AWS region (eg ap-southeast-2)
-
aws_access_key_id: the AWS access key
-
aws_secret_access_key: the AWS secret access key
-
aws_profile: AWS profile name
@return new RubyAemAws::AemAws
instance
# File lib/ruby_aem_aws_odysseas.rb, line 28 def initialize(conf = {}) conf[:region] ||= Constants::REGION_DEFAULT conf[:aws_access_key_id] ||= Constants::ACCESS_KEY_ID conf[:aws_secret_access_key] ||= Constants::SECRET_ACCESS_KEY conf[:aws_profile] ||= Constants::PROFILE Aws.config.update(region: conf[:region]) credentials = Aws::Credentials.new(conf[:aws_access_key_id], conf[:aws_secret_access_key]) unless conf[:aws_access_key_id].nil? credentials = Aws::SharedCredentials.new(profile_name: conf[:aws_profile]) unless conf[:aws_profile].nil? credentials = Aws::InstanceProfileCredentials.new if conf[:aws_profile].nil? && conf[:aws_access_key_id].nil? raise RubyAemAws::ArgumentError unless defined? credentials Aws.config.update(credentials: credentials) @aws = AwsCreator.create_aws end
Public Instance Methods
Create a consolidated instance.
@param stack_prefix AWS tag: StackPrefix @param aws_clients Array of AWS Clients and Resource connections:
-
CloudFormationClient: AWS Cloudformation Client.
-
CloudWatchClient: AWS Cloudwatch Client.
-
CloudWatchLogsClient: AWS Cloudwatch Logs Client.
-
Ec2Resource: AWS EC2 Resource connection.
@return new RubyAemAws::ConsolidatedStack
instance
# File lib/ruby_aem_aws_odysseas.rb, line 67 def consolidated(stack_prefix) aws_clients = { CloudFormationClient: @aws[:CloudFormationClient], CloudWatchClient: @aws[:CloudWatchClient], CloudWatchLogsClient: @aws[:CloudWatchLogsClient], Ec2Resource: @aws[:Ec2Resource] } RubyAemAws::ConsolidatedStack.new(stack_prefix, aws_clients) end
Create a full set instance.
@param stack_prefix AWS tag: StackPrefix @param aws_clients Array of AWS Clients and Resource connections:
-
AutoScalingClient: AWS AutoScalingGroup Client.
-
CloudFormationClient: AWS Cloudformation Client.
-
CloudWatchClient: AWS Cloudwatch Client.
-
CloudWatchLogsClient: AWS Cloudwatch Logs Client.
-
Ec2Resource: AWS EC2 Resource connection.
-
ElbClient: AWS ElasticLoadBalancer Client.
@return new RubyAemAws::FullSetStack
instance
# File lib/ruby_aem_aws_odysseas.rb, line 89 def full_set(stack_prefix) aws_clients = { AutoScalingClient: @aws[:AutoScalingClient], CloudFormationClient: @aws[:CloudFormationClient], CloudWatchClient: @aws[:CloudWatchClient], CloudWatchLogsClient: @aws[:CloudWatchLogsClient], Ec2Resource: @aws[:Ec2Resource], ElbClient: @aws[:ElbClient] } RubyAemAws::FullSetStack.new(stack_prefix, aws_clients) end
Create Stack Manager resources
@param stack_prefix AWS tag: StackPrefix @param aws_clients Array of AWS Clients and Resource connections:
-
CloudFormationClient: AWS Cloudformation Client.
-
CloudWatchClient: AWS Cloudwatch Client.
-
CloudWatchLogsClient: AWS Cloudwatch Logs Client.
-
DynamoDBClient: AWS
DynamoDB
Client. -
S3Client: AWS S3 Client.
-
S3Resource: AWS S3 Resource connection.
@return new RubyAemAws::StackManager
instance
# File lib/ruby_aem_aws_odysseas.rb, line 113 def stack_manager(stack_prefix) aws_clients = { CloudFormationClient: @aws[:CloudFormationClient], CloudWatchClient: @aws[:CloudWatchClient], CloudWatchLogsClient: @aws[:CloudWatchLogsClient], DynamoDBClient: @aws[:DynamoDBClient], S3Client: @aws[:S3Client], S3Resource: @aws[:S3Resource] } RubyAemAws::StackManager.new(stack_prefix, aws_clients) end
Test connection to Amazon AWS
@return One or more regions that are currently available.
# File lib/ruby_aem_aws_odysseas.rb, line 49 def test_connection result = [] ec2_client = @aws[:Ec2Client] ec2_client.describe_regions.regions.each do |region| result.push("Region #{region.region_name} (#{region.endpoint})") end !result.empty? end