mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add CloudFormation UpdateStack call
This commit is contained in:
parent
a61be1055a
commit
287c37abb2
4 changed files with 96 additions and 0 deletions
|
@ -9,6 +9,7 @@ module Fog
|
||||||
|
|
||||||
request_path 'fog/aws/requests/cloud_formation'
|
request_path 'fog/aws/requests/cloud_formation'
|
||||||
request :create_stack
|
request :create_stack
|
||||||
|
request :update_stack
|
||||||
request :delete_stack
|
request :delete_stack
|
||||||
request :describe_stack_events
|
request :describe_stack_events
|
||||||
request :describe_stack_resources
|
request :describe_stack_resources
|
||||||
|
|
19
lib/fog/aws/parsers/cloud_formation/update_stack.rb
Normal file
19
lib/fog/aws/parsers/cloud_formation/update_stack.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
module Fog
|
||||||
|
module Parsers
|
||||||
|
module AWS
|
||||||
|
module CloudFormation
|
||||||
|
|
||||||
|
class UpdateStack < Fog::Parsers::Base
|
||||||
|
|
||||||
|
def end_element(name)
|
||||||
|
case name
|
||||||
|
when 'RequestId', 'StackId'
|
||||||
|
@response[name] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
62
lib/fog/aws/requests/cloud_formation/update_stack.rb
Normal file
62
lib/fog/aws/requests/cloud_formation/update_stack.rb
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class CloudFormation
|
||||||
|
class Real
|
||||||
|
|
||||||
|
require 'fog/aws/parsers/cloud_formation/update_stack'
|
||||||
|
|
||||||
|
# Update a stack
|
||||||
|
#
|
||||||
|
# ==== Parameters
|
||||||
|
# * stack_name<~String>: name of the stack to update
|
||||||
|
# * options<~Hash>:
|
||||||
|
# * TemplateBody<~String>: structure containing the template body
|
||||||
|
# or (one of the two Template parameters is required)
|
||||||
|
# * 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
|
||||||
|
#
|
||||||
|
# ==== Returns
|
||||||
|
# * response<~Excon::Response>:
|
||||||
|
# * body<~Hash>:
|
||||||
|
# * 'StackId'<~String> - Id of the stack being updated
|
||||||
|
#
|
||||||
|
# ==== See Also
|
||||||
|
# http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html
|
||||||
|
#
|
||||||
|
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
|
|
@ -18,6 +18,11 @@ Shindo.tests('AWS::CloudFormation | stack requests', ['aws', 'cloudformation'])
|
||||||
'StackId' => String
|
'StackId' => String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@update_stack_format = {
|
||||||
|
'RequestId' => String,
|
||||||
|
'StackId' => String
|
||||||
|
}
|
||||||
|
|
||||||
@get_template_format = {
|
@get_template_format = {
|
||||||
'RequestId' => String,
|
'RequestId' => String,
|
||||||
'TemplateBody' => String
|
'TemplateBody' => String
|
||||||
|
@ -103,6 +108,15 @@ Shindo.tests('AWS::CloudFormation | stack requests', ['aws', 'cloudformation'])
|
||||||
).body
|
).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("update_stack('#{@stack_name}', 'TemplateURL' => '#{@template_url}', Parameters => {'KeyName' => 'cloudformation'})").formats(@update_stack_format) do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
Fog::AWS[:cloud_formation].update_stack(
|
||||||
|
@stack_name,
|
||||||
|
'TemplateURL' => @template_url,
|
||||||
|
'Parameters' => {'KeyName' => 'cloudformation'}
|
||||||
|
).body
|
||||||
|
end
|
||||||
|
|
||||||
tests("get_template('#{@stack_name})").formats(@get_template_format) do
|
tests("get_template('#{@stack_name})").formats(@get_template_format) do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
Fog::AWS[:cloud_formation].get_template(@stack_name).body
|
Fog::AWS[:cloud_formation].get_template(@stack_name).body
|
||||||
|
|
Loading…
Add table
Reference in a new issue