class AwsClient::Container

Public Class Methods

new(credentials_key, aws_region, provisioning_region) click to toggle source
# File lib/aws_client.rb, line 22
def initialize(credentials_key, aws_region, provisioning_region)
  @aws_account_credentials_key = credentials_key
  @aws_region = aws_region
  @provisioning_region = provisioning_region
  validate
end

Public Instance Methods

cloudformation() click to toggle source
# File lib/aws_client.rb, line 33
def cloudformation
  @cloudformation ||= ::AwsClient::CfWrapper.new(client: client_connect(::Aws::CloudFormation::Client))
end
ec2() click to toggle source
# File lib/aws_client.rb, line 45
def ec2
  @ec2 ||= ::AwsClient::Ec2Wrapper.new(client: client_connect(::Aws::EC2::Client))
end
elasticache() click to toggle source
# File lib/aws_client.rb, line 53
def elasticache
  @elasticache ||= ::AwsClient::ElastiCacheWrapper.new(client: client_connect(::Aws::ElastiCache::Client))
end
elasticsearch() click to toggle source
# File lib/aws_client.rb, line 57
def elasticsearch
  @elasticsearch ||= ::AwsClient::ElasticSearchWrapper.new(client: client_connect(::Aws::ElasticsearchService::Client))
end
elb() click to toggle source
# File lib/aws_client.rb, line 49
def elb
  @elb ||= ::AwsClient::ElbWrapper.new(client: client_connect(::Aws::ElasticLoadBalancing::Client))
end
rds() click to toggle source
# File lib/aws_client.rb, line 29
def rds
  @rds ||= ::AwsClient::RdsWrapper.new(client: client_connect(::Aws::RDS::Client))
end
s3() click to toggle source
# File lib/aws_client.rb, line 41
def s3
  @s3 ||= ::AwsClient::S3Wrapper.new(client: client_connect(::Aws::S3::Client), credentials_key: @aws_account_credentials_key, region: @aws_region)
end
s32() click to toggle source
# File lib/aws_client.rb, line 37
def s32
  @s32 ||= ::AwsClient::S32Wrapper.new(client: client_connect(::Aws::S3::Client), credentials_key: @aws_account_credentials_key, region: @aws_region)
end

Protected Instance Methods

credentials() click to toggle source
# File lib/aws_client.rb, line 63
def credentials
  all_credentials = YAML.load_file(::AwsClient::PATH_TO_CREDENTIALS)
  raise "Cannot find credentials for '#{@aws_account_credentials_key}'" unless all_credentials.has_key?(@aws_account_credentials_key)
  creds_for_key = all_credentials[@aws_account_credentials_key]
  return Aws::Credentials.new(creds_for_key["aws_access_key_id"], creds_for_key["aws_secret_access_key"])
end
validate() click to toggle source
# File lib/aws_client.rb, line 70
def validate
  raise "Missing Aws Account Credentials Key" unless @aws_account_credentials_key
  raise "Missing credentials file: cannot find #{::AwsClient::CREDENTIALS_FILE} in your home directory" unless File.exists?(::AwsClient::PATH_TO_CREDENTIALS)
end

Private Instance Methods

client_connect(client_klass) click to toggle source
# File lib/aws_client.rb, line 77
def client_connect(client_klass)
  return client_klass.new(credentials: credentials, region: @provisioning_region)
end