Sha256: 7d3a833f5b522c96fcae2af0179cbb5661bc948054a00c5649b50e17fd99db35

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'aws-sdk-dynamodb'

Aws.use_bundled_cert!

module TerraformDevKit
  module Aws
    # Wrapper class around aws dynamodb
    class DynamoDB
      def initialize(credentials, region)
        @db_client = ::Aws::DynamoDB::Client.new(
          credentials: credentials,
          region: region
        )
      end

      def put_item(table_name, item)
        @db_client.put_item({item: item, table_name: table_name})
      end

      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

      def get_table_status(table_name)
        resp = @db_client.describe_table({
          table_name: table_name,
        })
        resp.table.table_status
      end

      def delete_table(table_name)
        @db_client.delete_table({
          table_name: table_name,
        })
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
TerraformDevKit-0.3.8 lib/TerraformDevKit/aws/dynamodb.rb
TerraformDevKit-0.3.3 lib/TerraformDevKit/aws/dynamodb.rb
TerraformDevKit-0.3.1 lib/TerraformDevKit/aws/dynamodb.rb
TerraformDevKit-0.3.1.pre.rc1 lib/TerraformDevKit/aws/dynamodb.rb