Skip to content

Commit

Permalink
Bugfix: support for --region option
Browse files Browse the repository at this point in the history
[close #54]
  • Loading branch information
jonaf committed Jul 14, 2015
1 parent 17264a8 commit a86e8b1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/cloudformation-ruby-dsl/cfntemplate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,25 @@
class AwsCfn
attr_accessor :cfn_client_instance

def initialize(**args)
Aws.config[:region] = args[:region] if args.key?(:region)
end

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
validate_params: false,
)
end
@cfn_client_instance
end
end

# utility class to deserialize Structs as JSON
# borrowed from http://ruhe.tumblr.com/post/565540643/generate-json-from-ruby-struct
class Struct
def to_map
map = Hash.new
Expand Down Expand Up @@ -127,7 +132,7 @@ def validate_action(action)
end

def cfn(template)
aws_cfn = AwsCfn.new
aws_cfn = AwsCfn.new(region: template.aws_region)
cfn_client = aws_cfn.cfn_client

action = validate_action( ARGV[0] )
Expand Down

0 comments on commit a86e8b1

Please sign in to comment.