class Xaases::Aws::Dynamodb

Attributes

keys[R]
name[R]

Public Class Methods

new(name, *keys) click to toggle source
# File lib/xaases/aws/dynamodb.rb, line 5
def initialize(name, *keys)
  @name = name
  @keys = keys
end

Public Instance Methods

attribute_definitions() click to toggle source
# File lib/xaases/aws/dynamodb.rb, line 10
def attribute_definitions
  keys.map do |key, type|
    {
      "AttributeName" => key,
      "AttributeType" => (type == 'integer' ? 'N' : 'S')
    }
  end
end
key_schema() click to toggle source
# File lib/xaases/aws/dynamodb.rb, line 19
def key_schema
  i = 0
  keys.map do |key, type|
    i += 1
    {
      "AttributeName" => key,
      "KeyType" => (i == 1 ? 'HASH' : 'RANGE')
    }
  end
end
to_hash() click to toggle source
# File lib/xaases/aws/dynamodb.rb, line 30
def to_hash
  {
    "Type" => 'AWS::DynamoDB::Table',
    "Properties" => {
      "TableName" => name,
      "AttributeDefinitions" => attribute_definitions,
      "KeySchema" => key_schema,
      "ProvisionedThroughput" => {
        "ReadCapacityUnits" => 1,
        "WriteCapacityUnits" => 1
      }
    }
  }
end