1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

stack policy

This commit is contained in:
Neill Turner 2016-09-13 14:52:54 +01:00
parent 340e306c50
commit 8ac209176e
5 changed files with 92 additions and 0 deletions

View file

@ -22,8 +22,10 @@ module Fog
request :describe_stacks
request :estimate_template_cost
request :execute_change_set
request :get_stack_policy
request :get_template
request :get_template_summary
request :set_stack_policy
request :signal_resource
request :validate_template
request :list_change_sets

View file

@ -0,0 +1,16 @@
module Fog
module Parsers
module AWS
module CloudFormation
class GetStackPolicy < Fog::Parsers::Base
def end_element(name)
case name
when 'RequestId', 'StackPolicyBody'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -16,6 +16,9 @@ module Fog
# * Parameters [Hash] Hash of providers to supply to template
# * TimeoutInMinutes [Integer] Minutes to wait before status is set to CREATE_FAILED
# * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources
# * StackPolicyBody [String] Structure containing the stack policy body.
# * StackPolicyURL [String] URL of file containing the stack policy.
# * Tags [Array] Key-value pairs to associate with this stack.
#
# @return [Excon::Response]:
# * body [Hash:
@ -69,6 +72,12 @@ module Fog
params['TemplateURL'] = options['TemplateURL']
end
if options['StackPolicyBody']
params['StackPolicyBody'] = options['StackPolicyBody']
elsif options['StackPolicyURL']
params['StackPolicyURL'] = options['StackPolicyURL']
end
if options['TimeoutInMinutes']
params['TimeoutInMinutes'] = options['TimeoutInMinutes']
end

View file

@ -0,0 +1,27 @@
module Fog
module AWS
class CloudFormation
class Real
require 'fog/aws/parsers/cloud_formation/get_stack_policy'
# Describe stacks.
#
# @param stack_name [String] The name or unique stack ID that is associated with the stack whose policy you want to get.
#
# @return [Excon::Response]
# * body [Hash]:
# * StackPolicyBody [String] - Structure containing the stack policy body.
#
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_GetStackPolicy.html
def get_stack_policy(stack_name)
request(
'Action' => 'GetStackPolicy',
'StackName' => stack_name,
:parser => Fog::Parsers::AWS::CloudFormation::GetStackPolicy.new
)
end
end
end
end
end

View file

@ -0,0 +1,38 @@
module Fog
module AWS
class CloudFormation
class Real
require 'fog/aws/parsers/cloud_formation/basic'
# Sets a stack policy for a specified stack.
#
# @param stack_name [String] Name or unique stack ID that you want to associate a policy with.
# * options [Hash]:
# * StackPolicyBody [String] Structure containing the stack policy body.
# or (one of the two StackPolicy parameters is required)
# * StackPolicyURL [String] URL of file containing the stack policy.
# * Parameters [Hash] Hash of providers to supply to StackPolicy
#
# @return [Excon::Response]:
#
# @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_SetStackPolicy.html
def set_stack_policy(stack_name, options = {})
params = {}
if options['StackPolicyBody']
params['StackPolicyBody'] = options['StackPolicyBody']
elsif options['StackPolicyURL']
params['StackPolicyURL'] = options['StackPolicyURL']
end
request({
'Action' => 'SetStackPolicy',
'StackName' => stack_name,
:parser => Fog::Parsers::AWS::CloudFormation::Basic.new
}.merge!(params))
end
end
end
end
end