github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/website/source/docs/providers/aws/r/dynamodb_table.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: dynamodb_table"
     4  sidebar_current: "docs-aws-resource-dynamodb-table"
     5  description: |-
     6    Provides a DynamoDB table resource
     7  ---
     8  
     9  # aws\_dynamodb\_table
    10  
    11  Provides a DynamoDB table resource
    12  
    13  ## Example Usage
    14  
    15  The following dynamodb table description models the table and GSI shown
    16  in the [AWS SDK example documentation](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html)
    17  
    18  ```hcl
    19  resource "aws_dynamodb_table" "basic-dynamodb-table" {
    20    name           = "GameScores"
    21    read_capacity  = 20
    22    write_capacity = 20
    23    hash_key       = "UserId"
    24    range_key      = "GameTitle"
    25  
    26    attribute {
    27      name = "UserId"
    28      type = "S"
    29    }
    30  
    31    attribute {
    32      name = "GameTitle"
    33      type = "S"
    34    }
    35  
    36    attribute {
    37      name = "TopScore"
    38      type = "N"
    39    }
    40  
    41    ttl {
    42      attribute_name = "TimeToExist"
    43      enabled = false
    44    }
    45  
    46    global_secondary_index {
    47      name               = "GameTitleIndex"
    48      hash_key           = "GameTitle"
    49      range_key          = "TopScore"
    50      write_capacity     = 10
    51      read_capacity      = 10
    52      projection_type    = "INCLUDE"
    53      non_key_attributes = ["UserId"]
    54    }
    55  
    56    tags {
    57      Name        = "dynamodb-table-1"
    58      Environment = "production"
    59    }
    60  }
    61  ```
    62  
    63  ## Argument Reference
    64  
    65  The following arguments are supported:
    66  
    67  * `name` - (Required) The name of the table, this needs to be unique
    68    within a region.
    69  * `read_capacity` - (Required) The number of read units for this table
    70  * `write_capacity` - (Required) The number of write units for this table
    71  * `hash_key` - (Required, Forces new resource) The attribute to use as the hash key (the
    72    attribute must also be defined as an attribute record
    73  * `range_key` - (Optional, Forces new resource) The attribute to use as the range key (must
    74    also be defined)
    75  * `attribute` - Define an attribute, has two properties:
    76    * `name` - The name of the attribute
    77    * `type` - One of: S, N, or B for (S)tring, (N)umber or (B)inary data
    78  * `stream_enabled` - (Optional) Indicates whether Streams are to be enabled (true) or disabled (false).
    79  * `stream_view_type` - (Optional) When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES.
    80  * `ttl` - (Optional) Defines ttl, has two properties, and can only be specified once:
    81    * `enabled` - (Required) Indicates whether ttl is enabled (true) or disabled (false).
    82    * `attribute_name` - (Required) The name of the table attribute to store the TTL timestamp in. 
    83  * `local_secondary_index` - (Optional, Forces new resource) Describe an LSI on the table;
    84    these can only be allocated *at creation* so you cannot change this
    85  definition after you have created the resource.
    86  * `global_secondary_index` - (Optional) Describe a GSO for the table;
    87    subject to the normal limits on the number of GSIs, projected
    88  attributes, etc.
    89  * `tags` - (Optional) A map of tags to populate on the created table.
    90  
    91  For both `local_secondary_index` and `global_secondary_index` objects,
    92  the following properties are supported:
    93  
    94  * `name` - (Required) The name of the LSI or GSI
    95  * `hash_key` - (Required for GSI) The name of the hash key in the index; must be
    96  defined as an attribute in the resource. Only applies to
    97    `global_secondary_index`
    98  * `range_key` - (Required) The name of the range key; must be defined
    99  * `projection_type` - (Required) One of "ALL", "INCLUDE" or "KEYS_ONLY"
   100     where *ALL* projects every attribute into the index, *KEYS_ONLY*
   101      projects just the hash and range key into the index, and *INCLUDE*
   102      projects only the keys specified in the _non_key_attributes_
   103  parameter.
   104  * `non_key_attributes` - (Optional) Only required with *INCLUDE* as a
   105    projection type; a list of attributes to project into the index. These
   106  do not need to be defined as attributes on the table.
   107  
   108  For `global_secondary_index` objects only, you need to specify
   109  `write_capacity` and `read_capacity` in the same way you would for the
   110  table as they have separate I/O capacity.
   111  
   112  ### A note about attributes
   113  
   114  Only define attributes on the table object that are going to be used as:
   115  
   116  * Table hash key or range key
   117  * LSI or GSI hash key or range key
   118  
   119  The DynamoDB API expects attribute structure (name and type) to be
   120  passed along when creating or updating GSI/LSIs or creating the initial
   121  table. In these cases it expects the Hash / Range keys to be provided;
   122  because these get re-used in numerous places (i.e the table's range key
   123  could be a part of one or more GSIs), they are stored on the table
   124  object to prevent duplication and increase consistency. If you add
   125  attributes here that are not used in these scenarios it can cause an
   126  infinite loop in planning.
   127  
   128  
   129  ## Attributes Reference
   130  
   131  The following attributes are exported:
   132  
   133  * `arn` - The arn of the table
   134  * `id` - The name of the table
   135  * `stream_arn` - The ARN of the Table Stream. Only available when `stream_enabled = true`
   136  
   137  
   138  ## Import
   139  
   140  DynamoDB tables can be imported using the `name`, e.g.
   141  
   142  ```
   143  $ terraform import aws_dynamodb_table.basic-dynamodb-table GameScores
   144  ```