Module: Tfrb::Resource::AwsDynamodbTable

Extended by:
Tfrb::Resource
Defined in:
lib/tfrb/resource/aws_dynamodb_table.rb

Class Method Summary collapse

Methods included from Tfrb::Resource

aws_options, extended, get_custom_resource, get_state, import!, load_helpers!, resolve_tfvar, set_default

Class Method Details

.load(base, environment_name, resource_type, new_resources) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tfrb/resource/aws_dynamodb_table.rb', line 12

def self.load(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    client = ::Aws::DynamoDB::Client.new(aws_options(base, resource))
    begin
      response = client.describe_table({
        table_name: resource_name
      })
      id = response.table.table_name
      import!(base, resource_type, resource_name, id)
    rescue ::Aws::DynamoDB::Errors::TableNotFoundException, ::Aws::DynamoDB::Errors::ResourceNotFoundException
      # Does not exist to import
    end
  end
end

.preload(base, environment_name, resource_type, new_resources) ⇒ Object



6
7
8
9
10
# File 'lib/tfrb/resource/aws_dynamodb_table.rb', line 6

def self.preload(base, environment_name, resource_type, new_resources)
  new_resources.each do |resource_name, resource|
    set_default(resource, 'name', resource_name)
  end
end