Class: AwsCfn

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudformation-ruby-dsl/cfntemplate.rb

Overview

AWS SDK Support

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ AwsCfn

Returns a new instance of AwsCfn.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cloudformation-ruby-dsl/cfntemplate.rb', line 37

def initialize(args)
  Aws.config[:region] = args[:region] if args.key?(:region)
  # Profile definition was replaced with environment variables
  if args.key?(:aws_profile) && !(args[:aws_profile].nil? || args[:aws_profile].empty?)
      ENV['AWS_PROFILE'] = args[:aws_profile]
      ENV['AWS_ACCESS_KEY'] = nil
      ENV['AWS_ACCESS_KEY_ID'] = nil
      ENV['AMAZON_ACCESS_KEY_ID'] = nil
  end
  # Following line can be uncommented only when Amazon will provide the stable version of this functionality.
  # Aws.config[:credentials] = Aws::SharedCredentials.new(profile_name: args[:aws_profile]) unless args[:aws_profile].nil?
end

Instance Attribute Details

#cfn_client_instanceObject

Returns the value of attribute cfn_client_instance.



35
36
37
# File 'lib/cloudformation-ruby-dsl/cfntemplate.rb', line 35

def cfn_client_instance
  @cfn_client_instance
end

Instance Method Details

#cfn_clientObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cloudformation-ruby-dsl/cfntemplate.rb', line 50

def cfn_client
  if @cfn_client_instance == nil
      # credentials are loaded from the environment; see http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html
      @cfn_client_instance = Aws::CloudFormation::Client.new(
      # we don't validate parameters because the aws-ruby-sdk gets a number parameter and expects it to be a string and fails the validation
      # see: https://github.com/aws/aws-sdk-ruby/issues/848
      validate_params: false
    )
  end
  @cfn_client_instance
end