FEATURES PRICING ABOUT DOCS LOGIN

aws_dynamodb_table

Provides a DynamoDB table resource

Example Usage

The following dynamodb table description models the table and GSI shown in the AWS SDK example documentation

resource "aws_dynamodb_table" "basic-dynamodb-table" {
    name = "GameScores"
    read_capacity = 20
    write_capacity = 20
    hash_key = "UserId"
    range_key = "GameTitle"
    attribute {
      name = "UserId"
      type = "S"
    }
    attribute {
      name = "GameTitle"
      type = "S"
    }
    attribute {
      name = "TopScore"
      type = "N"
    }
    global_secondary_index {
      name = "GameTitleIndex"
      hash_key = "GameTitle"
      range_key = "TopScore"
      write_capacity = 10
      read_capacity = 10
      projection_type = "INCLUDE"
      non_key_attributes = [ "UserId" ]
    }
}

Argument Reference

The following arguments are supported:

For both local_secondary_index and global_secondary_index objects, the following properties are supported:

For global_secondary_index objects only, you need to specify write_capacity and read_capacity in the same way you would for the table as they have separate I/O capacity.

A note about attributes

Only define attributes on the table object that are going to be used as:

The DynamoDB API expects attribute structure (name and type) to be passed along when creating or updating GSI/LSIs or creating the initial table. In these cases it expects the Hash / Range keys to be provided; because these get re-used in numerous places (i.e the table’s range key could be a part of one or more GSIs), they are stored on the table object to prevent duplication and increase consistency. If you add attributes here that are not used in these scenarios it can cause an infinite loop in planning.

Attributes Reference

The following attributes are exported:


See the source of this document at Terraform.io

REQUEST A DEMO