class TerraformDevKit::Aws::DynamoDB

Wrapper class around aws dynamodb

Public Class Methods

new(credentials, region) click to toggle source
# File lib/TerraformDevKit/aws/dynamodb.rb, line 9
def initialize(credentials, region)
  @db_client = ::Aws::DynamoDB::Client.new(
    credentials: credentials,
    region: region
  )
end

Public Instance Methods

create_table(table_name, attributes, keys, read_capacity, write_capacity) click to toggle source
# File lib/TerraformDevKit/aws/dynamodb.rb, line 20
def create_table(table_name, attributes, keys, read_capacity, write_capacity)
  @db_client.create_table(
    attribute_definitions: attributes,
    key_schema: keys,
    provisioned_throughput: {
      read_capacity_units: read_capacity,
      write_capacity_units: write_capacity
    },
    table_name: table_name
  )
end
delete_table(table_name) click to toggle source
# File lib/TerraformDevKit/aws/dynamodb.rb, line 39
def delete_table(table_name)
  @db_client.delete_table({
    table_name: table_name,
  })
end
get_table_status(table_name) click to toggle source
# File lib/TerraformDevKit/aws/dynamodb.rb, line 32
def get_table_status(table_name)
  resp = @db_client.describe_table({
    table_name: table_name,
  })
  resp.table.table_status
end
put_item(table_name, item) click to toggle source
# File lib/TerraformDevKit/aws/dynamodb.rb, line 16
def put_item(table_name, item)
  @db_client.put_item({item: item, table_name: table_name})
end