Class: Fog::AWS::CloudFormation::Real
- Inherits:
-
Object
- Object
- Fog::AWS::CloudFormation::Real
- Defined in:
- lib/fog/aws/cloud_formation.rb,
lib/fog/aws/requests/cloud_formation/list_stacks.rb,
lib/fog/aws/requests/cloud_formation/create_stack.rb,
lib/fog/aws/requests/cloud_formation/delete_stack.rb,
lib/fog/aws/requests/cloud_formation/get_template.rb,
lib/fog/aws/requests/cloud_formation/update_stack.rb,
lib/fog/aws/requests/cloud_formation/describe_stacks.rb,
lib/fog/aws/requests/cloud_formation/signal_resource.rb,
lib/fog/aws/requests/cloud_formation/get_stack_policy.rb,
lib/fog/aws/requests/cloud_formation/list_change_sets.rb,
lib/fog/aws/requests/cloud_formation/set_stack_policy.rb,
lib/fog/aws/requests/cloud_formation/create_change_set.rb,
lib/fog/aws/requests/cloud_formation/delete_change_set.rb,
lib/fog/aws/requests/cloud_formation/validate_template.rb,
lib/fog/aws/requests/cloud_formation/execute_change_set.rb,
lib/fog/aws/requests/cloud_formation/cancel_update_stack.rb,
lib/fog/aws/requests/cloud_formation/describe_change_set.rb,
lib/fog/aws/requests/cloud_formation/get_template_summary.rb,
lib/fog/aws/requests/cloud_formation/list_stack_resources.rb,
lib/fog/aws/requests/cloud_formation/describe_stack_events.rb,
lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb,
lib/fog/aws/requests/cloud_formation/describe_account_limits.rb,
lib/fog/aws/requests/cloud_formation/describe_stack_resource.rb,
lib/fog/aws/requests/cloud_formation/continue_update_rollback.rb,
lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb
Instance Method Summary collapse
-
#cancel_update_stack(stack_name) ⇒ Excon::Response
Cancels an update on the specified stack.
-
#continue_update_rollback(stack_name) ⇒ Excon::Response
For a specified stack that is in the UPDATE_ROLLBACK_FAILED state, continues rolling it back to the UPDATE_ROLLBACK_COMPLETE state.
-
#create_change_set(stack_name, options = {}) ⇒ Excon::Response
Create a Change Set.
-
#create_stack(stack_name, options = {}) ⇒ Excon::Response
Create a stack.
-
#delete_change_set(change_set_name, options = {}) ⇒ Excon::Response
Delete a change set.
-
#delete_stack(stack_name) ⇒ Excon::Response
Delete a stack.
-
#describe_account_limits ⇒ Excon::Response
Describe account_limits.
-
#describe_change_set(change_set_name, options = {}) ⇒ Excon::Response
Describe change_set.
-
#describe_stack_events(stack_name, options = {}) ⇒ Excon::Response
Describe stack events.
-
#describe_stack_resource(logical_resource_id, stack_name) ⇒ Excon::Response
Describe stack resource.
-
#describe_stack_resources(options = {}) ⇒ Excon::Response
Describe stack resources.
-
#describe_stacks(options = {}) ⇒ Excon::Response
Describe stacks.
-
#estimate_template_cost(options = {}) ⇒ Excon::Response
Returns the estimated monthly cost of a template.
-
#execute_change_set(change_set_name, options = {}) ⇒ Excon::Response
Execute a change set.
-
#get_stack_policy(stack_name) ⇒ Excon::Response
Describe stacks.
-
#get_template(stack_name) ⇒ Excon::Response
Describe stacks.
-
#get_template_summary(options = {}) ⇒ Excon::Response
Returns information about a new or existing template.
-
#initialize(options = {}) ⇒ Real
constructor
Initialize connection to CloudFormation.
-
#list_change_sets(stack_name, options = {}) ⇒ Excon::Response
List change sets.
-
#list_stack_resources(options = {}) ⇒ Excon::Response
List stack resources.
-
#list_stacks(options = {}) ⇒ Excon::Response
List stacks.
- #reload ⇒ Object
-
#set_stack_policy(stack_name, options = {}) ⇒ Excon::Response
Sets a stack policy for a specified stack.
-
#signal_resource(logical_resource_id, stack_name, status, unique_id) ⇒ Excon::Response
Sends a signal to the specified resource.
-
#update_stack(stack_name, options = {}) ⇒ Excon::Response
Update a stack.
-
#validate_template(options = {}) ⇒ Excon::Response
Describe stacks.
Methods included from Fog::AWS::CredentialFetcher::ConnectionMethods
#refresh_credentials_if_expired
Constructor Details
#initialize(options = {}) ⇒ Real
Initialize connection to CloudFormation
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
cf = CloudFormation.new( :aws_access_key_id => your_aws_access_key_id, :aws_secret_access_key => your_aws_secret_access_key )
Parameters
- options<~Hash> - config arguments for connection. Defaults to {}.
Returns
- CloudFormation object with connection to AWS.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fog/aws/cloud_formation.rb', line 60 def initialize(={}) @use_iam_profile = [:use_iam_profile] @instrumentor = [:instrumentor] @instrumentor_name = [:instrumentor_name] || 'fog.aws.cloud_formation' @connection_options = [:connection_options] || {} [:region] ||= 'us-east-1' @region = [:region] @host = [:host] || "cloudformation.#{[:region]}.amazonaws.com" @path = [:path] || '/' @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) setup_credentials() end |
Instance Method Details
#cancel_update_stack(stack_name) ⇒ Excon::Response
Cancels an update on the specified stack.
15 16 17 18 19 20 21 |
# File 'lib/fog/aws/requests/cloud_formation/cancel_update_stack.rb', line 15 def cancel_update_stack(stack_name) request( 'Action' => 'CancelUpdateStack', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::Basic.new ) end |
#continue_update_rollback(stack_name) ⇒ Excon::Response
For a specified stack that is in the UPDATE_ROLLBACK_FAILED state, continues rolling it back to the UPDATE_ROLLBACK_COMPLETE state.
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/cloud_formation/continue_update_rollback.rb', line 16 def continue_update_rollback(stack_name) request( 'Action' => 'ContinueUpdateRollback', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::Basic.new ) end |
#create_change_set(stack_name, options = {}) ⇒ Excon::Response
Create a Change Set.
- stack_name [String] Name of the stack to create.
- options [Hash]:
- ChangeSetName [String] The name of the change set.
- Description [String] A description to help you identify this change set.
- 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.
- UsePreviousTemplate [Boolean] Reuse the template that is associated with the stack to create the change set.
- NotificationARNs [Array] List of SNS topics to publish events to.
- Parameters [Hash] Hash of providers to supply to template.
- Capabilities [Array] List of capabilities the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fog/aws/requests/cloud_formation/create_change_set.rb', line 27 def create_change_set(stack_name, = {}) params = { 'StackName' => stack_name, } if ['ChangeSetName'] params['ChangeSetName'] = ['ChangeSetName'] end if ['Description'] params['Description'] = ['Description'] end if ['UsePreviousTemplate'] params['UsePreviousTemplate'] = ['UsePreviousTemplate'] end if ['NotificationARNs'] params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*['NotificationARNs']])) end if ['Parameters'] ['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" => ['Parameters'][key] }) end end if ['TemplateBody'] params['TemplateBody'] = ['TemplateBody'] elsif ['TemplateURL'] params['TemplateURL'] = ['TemplateURL'] end if ['Capabilities'] params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*['Capabilities']])) end request({ 'Action' => 'CreateChangeSet', :parser => Fog::Parsers::AWS::CloudFormation::CreateChangeSet.new }.merge!(params)) end |
#create_stack(stack_name, options = {}) ⇒ Excon::Response
Create a stack.
- stack_name [String] Name of the stack to create.
- 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.
- 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
- Capabilities [Array] List of capabilities 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fog/aws/requests/cloud_formation/create_stack.rb', line 30 def create_stack(stack_name, = {}) params = { 'StackName' => stack_name, } if ['DisableRollback'] params['DisableRollback'] = ['DisableRollback'] end if ['OnFailure'] params['OnFailure'] = ['OnFailure'] end if ['NotificationARNs'] params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*['NotificationARNs']])) end if ['Parameters'] ['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" => ['Parameters'][key] }) end end = 0 if ['Tags'] ['Tags'].keys.each_with_index do |key, index| index += 1 # tags are 1-indexed += 1 # 10 tag max params.merge!({ "Tags.member.#{index}.Key" => key, "Tags.member.#{index}.Value" => ['Tags'][key] }) end end if > 10 raise ArgumentError.new("a maximum of 10 tags can be specified <#{}>") end if ['TemplateBody'] params['TemplateBody'] = ['TemplateBody'] elsif ['TemplateURL'] params['TemplateURL'] = ['TemplateURL'] end if ['StackPolicyBody'] params['StackPolicyBody'] = ['StackPolicyBody'] elsif ['StackPolicyURL'] params['StackPolicyURL'] = ['StackPolicyURL'] end if ['TimeoutInMinutes'] params['TimeoutInMinutes'] = ['TimeoutInMinutes'] end if ['Capabilities'] params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*['Capabilities']])) end request({ 'Action' => 'CreateStack', :parser => Fog::Parsers::AWS::CloudFormation::CreateStack.new }.merge!(params)) end |
#delete_change_set(change_set_name, options = {}) ⇒ Excon::Response
Delete a change set.
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/cloud_formation/delete_change_set.rb', line 16 def delete_change_set(change_set_name, = {}) ['ChangeSetName'] = change_set_name request({ 'Action' => 'DeleteChangeSet', :parser => Fog::Parsers::AWS::CloudFormation::Basic.new }.merge!()) end |
#delete_stack(stack_name) ⇒ Excon::Response
Delete a stack.
15 16 17 18 19 20 21 |
# File 'lib/fog/aws/requests/cloud_formation/delete_stack.rb', line 15 def delete_stack(stack_name) request( 'Action' => 'DeleteStack', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::Basic.new ) end |
#describe_account_limits ⇒ Excon::Response
Describe account_limits.
18 19 20 21 22 23 |
# File 'lib/fog/aws/requests/cloud_formation/describe_account_limits.rb', line 18 def describe_account_limits() request( 'Action' => 'DescribeAccountLimits', :parser => Fog::Parsers::AWS::CloudFormation::DescribeAccountLimits.new ) end |
#describe_change_set(change_set_name, options = {}) ⇒ Excon::Response
Describe change_set.
- ChangeSetName [String] The name of the change set to describe.
33 34 35 36 37 38 39 |
# File 'lib/fog/aws/requests/cloud_formation/describe_change_set.rb', line 33 def describe_change_set(change_set_name, = {}) ['ChangeSetName'] = change_set_name request({ 'Action' => 'DescribeChangeSet', :parser => Fog::Parsers::AWS::CloudFormation::DescribeChangeSet.new }.merge!()) end |
#describe_stack_events(stack_name, options = {}) ⇒ Excon::Response
Describe stack events.
29 30 31 32 33 34 35 |
# File 'lib/fog/aws/requests/cloud_formation/describe_stack_events.rb', line 29 def describe_stack_events(stack_name, = {}) request({ 'Action' => 'DescribeStackEvents', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::DescribeStackEvents.new }.merge!()) end |
#describe_stack_resource(logical_resource_id, stack_name) ⇒ Excon::Response
Describe stack resource.
29 30 31 32 33 34 35 36 |
# File 'lib/fog/aws/requests/cloud_formation/describe_stack_resource.rb', line 29 def describe_stack_resource(logical_resource_id, stack_name ) request( 'Action' => 'DescribeStackResource', 'LogicalResourceId' => logical_resource_id, 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::DescribeStackResource.new ) end |
#describe_stack_resources(options = {}) ⇒ Excon::Response
Describe stack resources.
29 30 31 32 33 34 |
# File 'lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb', line 29 def describe_stack_resources( = {}) request({ 'Action' => 'DescribeStackResources', :parser => Fog::Parsers::AWS::CloudFormation::DescribeStackResources.new }.merge!()) end |
#describe_stacks(options = {}) ⇒ Excon::Response
Describe stacks.
28 29 30 31 32 33 |
# File 'lib/fog/aws/requests/cloud_formation/describe_stacks.rb', line 28 def describe_stacks( = {}) request({ 'Action' => 'DescribeStacks', :parser => Fog::Parsers::AWS::CloudFormation::DescribeStacks.new }.merge!()) end |
#estimate_template_cost(options = {}) ⇒ Excon::Response
Returns the estimated monthly cost of a template.
- 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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb', line 21 def estimate_template_cost( = {}) params = {} if ['Parameters'] ['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" => ['Parameters'][key] }) end end if ['TemplateBody'] params['TemplateBody'] = ['TemplateBody'] elsif ['TemplateURL'] params['TemplateURL'] = ['TemplateURL'] end request({ 'Action' => 'EstimateTemplateCost', :parser => Fog::Parsers::AWS::CloudFormation::EstimateTemplateCost.new }.merge!(params)) end |
#execute_change_set(change_set_name, options = {}) ⇒ Excon::Response
Execute a change set.
16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/cloud_formation/execute_change_set.rb', line 16 def execute_change_set(change_set_name, = {}) ['ChangeSetName'] = change_set_name request({ 'Action' => 'ExecuteChangeSet', :parser => Fog::Parsers::AWS::CloudFormation::Basic.new }.merge!()) end |
#get_stack_policy(stack_name) ⇒ Excon::Response
Describe stacks.
17 18 19 20 21 22 23 |
# File 'lib/fog/aws/requests/cloud_formation/get_stack_policy.rb', line 17 def get_stack_policy(stack_name) request( 'Action' => 'GetStackPolicy', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::GetStackPolicy.new ) end |
#get_template(stack_name) ⇒ Excon::Response
Describe stacks.
17 18 19 20 21 22 23 |
# File 'lib/fog/aws/requests/cloud_formation/get_template.rb', line 17 def get_template(stack_name) request( 'Action' => 'GetTemplate', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::GetTemplate.new ) end |
#get_template_summary(options = {}) ⇒ Excon::Response
Returns information about a new or existing template.
- options [Hash]:
- stack_name [String] Name of the stack or the stack ID. or
- TemplateBody [String] Structure containing the template body. or
- TemplateURL [String] URL of file containing the template body.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fog/aws/requests/cloud_formation/get_template_summary.rb', line 27 def get_template_summary( = {}) params = {} if ['StackName'] params['StackName'] = ['StackName'] elsif ['TemplateBody'] params['TemplateBody'] = ['TemplateBody'] elsif ['TemplateURL'] params['TemplateURL'] = ['TemplateURL'] end request({ 'Action' => 'GetTemplateSummary', :parser => Fog::Parsers::AWS::CloudFormation::GetTemplateSummary.new }.merge!(params)) end |
#list_change_sets(stack_name, options = {}) ⇒ Excon::Response
List change sets.
30 31 32 33 34 35 36 |
# File 'lib/fog/aws/requests/cloud_formation/list_change_sets.rb', line 30 def list_change_sets(stack_name, = {}) request({ 'Action' => 'ListChangeSets', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::ListChangeSets.new }.merge!()) end |
#list_stack_resources(options = {}) ⇒ Excon::Response
List stack resources.
25 26 27 28 29 30 |
# File 'lib/fog/aws/requests/cloud_formation/list_stack_resources.rb', line 25 def list_stack_resources( = {}) request({ 'Action' => 'ListStackResources', :parser => Fog::Parsers::AWS::CloudFormation::ListStackResources.new }.merge!()) end |
#list_stacks(options = {}) ⇒ Excon::Response
List stacks.
26 27 28 29 30 31 |
# File 'lib/fog/aws/requests/cloud_formation/list_stacks.rb', line 26 def list_stacks( = {}) request({ 'Action' => 'ListStacks', :parser => Fog::Parsers::AWS::CloudFormation::ListStacks.new }.merge!()) end |
#reload ⇒ Object
79 80 81 |
# File 'lib/fog/aws/cloud_formation.rb', line 79 def reload @connection.reset end |
#set_stack_policy(stack_name, options = {}) ⇒ Excon::Response
Sets a stack policy for a specified stack.
- 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/aws/requests/cloud_formation/set_stack_policy.rb', line 20 def set_stack_policy(stack_name, = {}) params = {} if ['StackPolicyBody'] params['StackPolicyBody'] = ['StackPolicyBody'] elsif ['StackPolicyURL'] params['StackPolicyURL'] = ['StackPolicyURL'] end request({ 'Action' => 'SetStackPolicy', 'StackName' => stack_name, :parser => Fog::Parsers::AWS::CloudFormation::Basic.new }.merge!(params)) end |
#signal_resource(logical_resource_id, stack_name, status, unique_id) ⇒ Excon::Response
Sends a signal to the specified resource.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/aws/requests/cloud_formation/signal_resource.rb', line 19 def signal_resource(logical_resource_id, stack_name, status, unique_id ) request( 'Action' => 'SignalResource', 'LogicalResourceId' => logical_resource_id, 'StackName' => stack_name, 'Status' => status, 'UniqueId' => unique_id, :parser => Fog::Parsers::AWS::CloudFormation::Basic.new ) end |
#update_stack(stack_name, options = {}) ⇒ Excon::Response
Update a stack.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fog/aws/requests/cloud_formation/update_stack.rb', line 31 def update_stack(stack_name, = {}) params = { 'StackName' => stack_name, } if ['Parameters'] ['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" => ['Parameters'][key] }) end end if ['TemplateBody'] params['TemplateBody'] = ['TemplateBody'] elsif ['TemplateURL'] params['TemplateURL'] = ['TemplateURL'] end if ['StackPolicyBody'] params['StackPolicyBody'] = ['StackPolicyBody'] elsif ['StackPolicyURL'] params['StackPolicyURL'] = ['StackPolicyURL'] end if ['StackPolicyDuringUpdateBody'] params['StackPolicyDuringUpdateBody'] = ['StackPolicyDuringUpdateBody'] elsif ['StackPolicyDuringUpdateURL'] params['StackPolicyDuringUpdateURL'] = ['StackPolicyDuringUpdateURL'] end = 0 if ['Tags'] ['Tags'].keys.each_with_index do |key, index| index += 1 # tags are 1-indexed += 1 # 10 tag max params.merge!({ "Tags.member.#{index}.Key" => key, "Tags.member.#{index}.Value" => ['Tags'][key] }) end end if > 10 raise ArgumentError.new("a maximum of 10 tags can be specified <#{}>") end if ['Capabilities'] params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*['Capabilities']])) end if ['NotificationARNs'] params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*['NotificationARNs']])) end if ['ResourceTypes'] params.merge!(Fog::AWS.indexed_param("ResourceTypes.member", [*['ResourceTypes']])) end if ['UsePreviousTemplate'] params['UsePreviousTemplate'] = ['UsePreviousTemplate'] end request({ 'Action' => 'UpdateStack', :parser => Fog::Parsers::AWS::CloudFormation::UpdateStack.new }.merge!(params)) end |
#validate_template(options = {}) ⇒ Excon::Response
Describe stacks.
20 21 22 23 24 25 |
# File 'lib/fog/aws/requests/cloud_formation/validate_template.rb', line 20 def validate_template( = {}) request({ 'Action' => 'ValidateTemplate', :parser => Fog::Parsers::AWS::CloudFormation::ValidateTemplate.new }.merge!()) end |