-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fog#568 from jameskilton/update_stack
Add CloudFormation UpdateStack API
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters