class RubyAemAws::AemAws

AemAws class represents the AWS stack for AEM.

Public Class Methods

new(conf = {}) click to toggle source

@param conf configuration hash of the following configuration values:

  • 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_profile: AWS profile name

@return new RubyAemAws::AemAws instance

# File lib/ruby_aem_aws.rb, line 28
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_profile] ||= Constants::PROFILE

  Aws.config.update(region: conf[:aws_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

consolidated(stack_prefix) click to toggle source

Create a consolidated instance.

@param stack_prefix AWS tag: StackPrefix @return new RubyAemAws::ConsolidatedStack instance

# File lib/ruby_aem_aws.rb, line 62
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) click to toggle source

Create a full set instance.

@param stack_prefix AWS tag: StackPrefix @return new RubyAemAws::FullSetStack instance

# File lib/ruby_aem_aws.rb, line 77
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) click to toggle source

Create Stack Manager resources

@param stack_prefix AWS tag: StackPrefix @return new RubyAemAws::StackManager instance

# File lib/ruby_aem_aws.rb, line 94
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() click to toggle source

Test connection to Amazon AWS

@return One or more regions that are currently available.

# File lib/ruby_aem_aws.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