Class: AwsHelpers::CloudFormation::StackDelete

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_helpers/cloud_formation/stack_delete.rb

Instance Method Summary collapse

Constructor Details

#initialize(cloud_formation_client, stack_name) ⇒ StackDelete

Returns a new instance of StackDelete


9
10
11
12
13
14
# File 'lib/aws_helpers/cloud_formation/stack_delete.rb', line 9

def initialize(cloud_formation_client, stack_name)
  @cloud_formation_client = cloud_formation_client
  @stack_name = stack_name
  @stack_exists = StackExists.new(cloud_formation_client, stack_name)
  @describe_stack = DescribeStack.new(cloud_formation_client, stack_name)
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
# File 'lib/aws_helpers/cloud_formation/stack_delete.rb', line 16

def execute
  puts "Deleting #{@stack_name}"
  return unless @stack_exists.execute

  stack = @describe_stack.execute
  stack_id = stack[:stack_id]
  @cloud_formation_client.delete_stack(stack_name: @stack_name)
  StackProgress.new(@cloud_formation_client, stack_id).execute
end