Class: RubyAemAws::AemAws
- Inherits:
-
Object
- Object
- RubyAemAws::AemAws
- Defined in:
- lib/ruby_aem_aws.rb
Overview
AemAws class represents the AWS stack for AEM.
Instance Method Summary collapse
-
#consolidated(stack_prefix) ⇒ Object
Create a consolidated instance.
-
#full_set(stack_prefix) ⇒ Object
Create a full set instance.
-
#initialize(conf = {}) ⇒ Object
constructor
-
aws_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_session_token: session token from STS - aws_profile: AWS profile name.
-
-
#stack_manager(stack_prefix) ⇒ Object
Create Stack Manager resources.
-
#test_connection ⇒ Object
Test connection to Amazon AWS.
Constructor Details
#initialize(conf = {}) ⇒ Object
-
aws_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_session_token: session token from STS
-
aws_profile: AWS profile name
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_aem_aws.rb', line 38 def initialize(conf = {}) conf[:aws_region] ||= Constants::REGION_DEFAULT conf[:aws_access_key_id] ||= Constants::ACCESS_KEY_ID conf[:aws_secret_access_key] ||= Constants::SECRET_ACCESS_KEY conf[:aws_session_token] ||= Constants::SESSION_TOKEN conf[:aws_profile] ||= Constants::PROFILE Aws.config.update(region: conf[:aws_region]) credentials = Aws::Credentials.new(conf[:aws_access_key_id], conf[:aws_secret_access_key], conf[:aws_session_token]) 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 |
Instance Method Details
#consolidated(stack_prefix) ⇒ Object
Create a consolidated instance.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ruby_aem_aws.rb', line 73 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 |
#full_set(stack_prefix) ⇒ Object
Create a full set instance.
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruby_aem_aws.rb', line 88 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 |
#stack_manager(stack_prefix) ⇒ Object
Create Stack Manager resources
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ruby_aem_aws.rb', line 105 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 ⇒ Object
Test connection to Amazon AWS
60 61 62 63 64 65 66 67 |
# File 'lib/ruby_aem_aws.rb', line 60 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 |