2011-10-18 10:06:35 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class CloudFormation
|
|
|
|
class Real
|
|
|
|
|
|
|
|
require 'fog/aws/parsers/cloud_formation/update_stack'
|
|
|
|
|
2013-03-10 18:17:56 -04:00
|
|
|
# Update a stack.
|
2011-10-18 10:06:35 -04:00
|
|
|
#
|
2013-05-02 07:22:05 -04:00
|
|
|
# @param [String] stack_name Name of the stack to update.
|
|
|
|
# @param [Hash] options
|
2013-03-10 18:17:56 -04:00
|
|
|
# * TemplateBody [String] Structure containing the template body.
|
2011-10-18 10:06:35 -04:00
|
|
|
# or (one of the two Template parameters is required)
|
2013-03-10 18:17:56 -04:00
|
|
|
# * 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.
|
2011-10-18 10:06:35 -04:00
|
|
|
#
|
2013-03-10 18:17:56 -04:00
|
|
|
# @return [Excon::Response]
|
|
|
|
# * body [Hash]:
|
|
|
|
# * StackId [String] - Id of the stack being updated
|
2011-10-18 10:06:35 -04:00
|
|
|
#
|
2013-03-10 18:17:56 -04:00
|
|
|
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html
|
2013-05-02 07:22:05 -04:00
|
|
|
#
|
2011-10-18 10:06:35 -04:00
|
|
|
def update_stack(stack_name, options = {})
|
|
|
|
params = {
|
|
|
|
'StackName' => stack_name,
|
|
|
|
}
|
|
|
|
|
|
|
|
if options['Parameters']
|
|
|
|
options['Parameters'].keys.each_with_index do |key, index|
|
|
|
|
index += 1 # params are 1-indexed
|
|
|
|
params.merge!({
|
|
|
|
"Parameters.member.#{index}.ParameterKey" => key,
|
|
|
|
"Parameters.member.#{index}.ParameterValue" => options['Parameters'][key]
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if options['TemplateBody']
|
|
|
|
params['TemplateBody'] = options['TemplateBody']
|
|
|
|
elsif options['TemplateURL']
|
|
|
|
params['TemplateURL'] = options['TemplateURL']
|
|
|
|
end
|
|
|
|
|
|
|
|
if options['Capabilities']
|
|
|
|
params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*options['Capabilities']]))
|
|
|
|
end
|
|
|
|
|
|
|
|
request({
|
|
|
|
'Action' => 'UpdateStack',
|
|
|
|
:parser => Fog::Parsers::AWS::CloudFormation::UpdateStack.new
|
|
|
|
}.merge!(params))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|