Module: AwsCftTools::Client::CFT::StackManagement
- Included in:
- AwsCftTools::Client::CFT
- Defined in:
- lib/aws_cft_tools/client/cft/stack_management.rb
Overview
Provide stack management functions for the CFT client.
Instance Method Summary collapse
-
#create_stack(template) ⇒ Object
Accepts information about a stack and tries to create the stack.
-
#delete_stack(template) ⇒ Object
Accepts information about a stack and tries to remove the stack.
-
#update_stack(template) ⇒ Object
Accepts information about a stack and tries to update that stack.
Instance Method Details
#create_stack(template) ⇒ Object
Accepts information about a stack and tries to create the stack. The stack must not exist in CloudFormation.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 46 def create_stack(template) throttle_backoff = 0 begin aws_client.create_stack(create_stack_params(template)) rescue Aws::CloudFormation::Errors::Throttling throttle_backoff += 0.5 sleep 2**throttle_backoff retry end # we want to wait for the create to complete before we proceed wait_for_stack_operation(:stack_create_complete, template.name) end |
#delete_stack(template) ⇒ Object
Accepts information about a stack and tries to remove the stack. The stack must exist in CloudFormation.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 65 def delete_stack(template) throttle_backoff = 0 begin aws_client.delete_stack(delete_stack_params(template)) rescue Aws::CloudFormation::Errors::Throttling throttle_backoff += 0.5 sleep 2**throttle_backoff retry end begin aws_client.wait_until(:stack_delete_complete, stack_name: template.name) rescue Aws::CloudFormation::Errors::Throttling throttle_backoff += 0.5 sleep 2**throttle_backoff retry end end |
#update_stack(template) ⇒ Object
Accepts information about a stack and tries to update that stack. The stack must already exist in CloudFormation.
Metadata keys:
-
filename (required)
-
name
-
parameters
-
template_file
If the update would result in no changes, no error is raised. Otherwise, all errors are raised and halt deployment.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 25 def update_stack(template) throttle_backoff = 0 begin aws_client.update_stack(update_stack_params(template)) rescue Aws::CloudFormation::Errors::Throttling throttle_backoff += 0.5 sleep 2**throttle_backoff retry end # we want to wait for the update to complete before we proceed wait_for_stack_operation(:stack_update_complete, template.name) rescue Aws::CloudFormation::Errors::ValidationError => exception raise exception unless exception..match?(/No updates/) end |