Class: Dynamocli::Erase

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamocli/erase.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_name:, with_drift: false) ⇒ Erase

Returns a new instance of Erase.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dynamocli/erase.rb', line 12

def initialize(table_name:, with_drift: false)
  @with_drift = with_drift
  @table_name = table_name

  @dynamodb = Aws::DynamoDB::Client.new
  @cloudformation = Aws::CloudFormation::Client.new
  @table_on_aws = Aws::DynamoDB::Table.new(@table_name)

  @stack_resources = @cloudformation.describe_stack_resources(physical_resource_id: @table_name).to_h
rescue Aws::CloudFormation::Errors::ValidationError
  @stack_resources = nil
end

Instance Method Details

#startObject



25
26
27
28
29
30
31
32
# File 'lib/dynamocli/erase.rb', line 25

def start
  erase_table
rescue Aws::CloudFormation::Errors::ValidationError,
       Aws::DynamoDB::Errors::ValidationException,
       Aws::DynamoDB::Errors::ResourceNotFoundException => e
  LOGGER.error(e.message)
  exit(42)
end