From a2f673031dda1ea7962e35247a78275bb9f41a42 Mon Sep 17 00:00:00 2001 From: Neill Turner Date: Wed, 14 Sep 2016 11:59:27 +0100 Subject: [PATCH] additional parameters --- .../requests/cloud_formation/create_stack.rb | 5 ++ .../requests/cloud_formation/update_stack.rb | 49 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/lib/fog/aws/requests/cloud_formation/create_stack.rb b/lib/fog/aws/requests/cloud_formation/create_stack.rb index a65cec745..5afbd8f91 100644 --- a/lib/fog/aws/requests/cloud_formation/create_stack.rb +++ b/lib/fog/aws/requests/cloud_formation/create_stack.rb @@ -12,6 +12,7 @@ module Fog # or (one of the two Template parameters is required) # * TemplateURL [String] URL of file containing the template body. # * DisableRollback [Boolean] Controls rollback on stack creation failure, defaults to false. + # * OnFailure [String] Determines what action will be taken if stack creation fails. This must be one of: DO_NOTHING, ROLLBACK, or DELETE. # * NotificationARNs [Array] List of SNS topics to publish events to. # * Parameters [Hash] Hash of providers to supply to template # * TimeoutInMinutes [Integer] Minutes to wait before status is set to CREATE_FAILED @@ -35,6 +36,10 @@ module Fog params['DisableRollback'] = options['DisableRollback'] end + if options['OnFailure'] + params['OnFailure'] = options['OnFailure'] + end + if options['NotificationARNs'] params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*options['NotificationARNs']])) end diff --git a/lib/fog/aws/requests/cloud_formation/update_stack.rb b/lib/fog/aws/requests/cloud_formation/update_stack.rb index d3722498c..decd9cae1 100644 --- a/lib/fog/aws/requests/cloud_formation/update_stack.rb +++ b/lib/fog/aws/requests/cloud_formation/update_stack.rb @@ -13,6 +13,14 @@ module Fog # * TemplateURL [String] URL of file containing the template body. # * Parameters [Hash] Hash of providers to supply to template. # * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources. + # * NotificationARNs [Array] List of SNS topics to publish events to. + # * ResourceTypes [Array] The template resource types that you have permissions to work. + # * StackPolicyBody [String] Structure containing the stack policy body. + # * StackPolicyURL [String] URL of file containing the stack policy. + # * StackPolicyDuringUpdateBody [String] Structure containing the stack policy body to use during update. + # * StackPolicyDuringUpdateURL [String] URL of file containing the stack policy to use during update. + # * Tags [Array] Key-value pairs to associate with this stack. + # * UsePreviousTemplate [Boolean] Reuse the existing template that is associated with the stack that you are updating. # # @return [Excon::Response] # * body [Hash]: @@ -41,10 +49,51 @@ module Fog params['TemplateURL'] = options['TemplateURL'] end + if options['StackPolicyBody'] + params['StackPolicyBody'] = options['StackPolicyBody'] + elsif options['StackPolicyURL'] + params['StackPolicyURL'] = options['StackPolicyURL'] + end + + if options['StackPolicyDuringUpdateBody'] + params['StackPolicyDuringUpdateBody'] = options['StackPolicyDuringUpdateBody'] + elsif options['StackPolicyDuringUpdateURL'] + params['StackPolicyDuringUpdateURL'] = options['StackPolicyDuringUpdateURL'] + end + + num_tags = 0 + if options['Tags'] + options['Tags'].keys.each_with_index do |key, index| + index += 1 # tags are 1-indexed + num_tags += 1 # 10 tag max + + params.merge!({ + "Tags.member.#{index}.Key" => key, + "Tags.member.#{index}.Value" => options['Tags'][key] + }) + end + end + + if num_tags > 10 + raise ArgumentError.new("a maximum of 10 tags can be specified <#{num_tags}>") + end + if options['Capabilities'] params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*options['Capabilities']])) end + if options['NotificationARNs'] + params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*options['NotificationARNs']])) + end + + if options['ResourceTypes'] + params.merge!(Fog::AWS.indexed_param("ResourceTypes.member", [*options['ResourceTypes']])) + end + + if options['UsePreviousTemplate'] + params['UsePreviousTemplate'] = options['UsePreviousTemplate'] + end + request({ 'Action' => 'UpdateStack', :parser => Fog::Parsers::AWS::CloudFormation::UpdateStack.new