Class: AwsHelpers::CloudFormation::StackExists

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

Instance Method Summary collapse

Constructor Details

#initialize(cloud_formation_client, stack_name) ⇒ StackExists

Returns a new instance of StackExists


8
9
10
11
# File 'lib/aws_helpers/cloud_formation/stack_exists.rb', line 8

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

Instance Method Details

#executeObject


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/aws_helpers/cloud_formation/stack_exists.rb', line 13

def execute
  begin
    !@describe_stack.execute.nil?
  rescue Aws::CloudFormation::Errors::ValidationError => validation_error
    if validation_error.message == "Stack with id #{@stack_name} does not exist"
      false
    else
      raise validation_error
    end
  end
end