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

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.

Parameters:



39
40
41
42
43
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 39

def create_stack(template)
  aws_client.create_stack(create_stack_params(template))
  # 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.

Parameters:



51
52
53
54
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 51

def delete_stack(template)
  aws_client.delete_stack(delete_stack_params(template))
  aws_client.wait_until(:stack_delete_complete, stack_name: template.name)
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.

Parameters:



25
26
27
28
29
30
31
# File 'lib/aws_cft_tools/client/cft/stack_management.rb', line 25

def update_stack(template)
  aws_client.update_stack(update_stack_params(template))
  # 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.message.match?(/No updates/)
end