github.com/atsaki/terraform@v0.4.3-0.20150919165407-25bba5967654/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](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html)
    17  
    18  ```
    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      attribute {
    26        name = "UserId"
    27        type = "S"
    28      }
    29      attribute {
    30        name = "GameTitle"
    31        type = "S"
    32      }
    33      attribute {
    34        name = "TopScore"
    35        type = "N"
    36      }
    37      global_secondary_index {
    38        name = "GameTitleIndex"
    39        hash_key = "GameTitle"
    40        range_key = "TopScore"
    41        write_capacity = 10
    42        read_capacity = 10
    43        projection_type = "INCLUDE"
    44        non_key_attributes = [ "UserId" ]
    45      }
    46  }
    47  ```
    48  
    49  ## Argument Reference
    50  
    51  The following arguments are supported:
    52  
    53  * `name` - (Required) The name of the table, this needs to be unique
    54    within a region.
    55  * `read_capacity` - (Required) The number of read units for this table
    56  * `write_capacity` - (Required) The number of write units for this table
    57  * `hash_key` - (Required) The attribute to use as the hash key (the
    58    attribute must also be defined as an attribute record
    59  * `range_key` - (Optional) The attribute to use as the range key (must
    60    also be defined)
    61  * `attribute` - Define an attribute, has two properties:
    62    * `name` - The name of the attribute
    63    * `type` - One of: S, N, or B for (S)tring, (N)umber or (B)inary data
    64  * `local_secondary_index` - (Optional) Describe an LSI on the table;
    65    these can only be allocated *at creation* so you cannot change this
    66  definition after you have created the resource.
    67  * `global_secondary_index` - (Optional) Describe a GSO for the table;
    68    subject to the normal limits on the number of GSIs, projected
    69  attributes, etc.  
    70  
    71  For both `local_secondary_index` and `global_secondary_index` objects,
    72  the following properties are supported:
    73  
    74  * `name` - (Required) The name of the LSI or GSI
    75  * `hash_key` - (Required) The name of the hash key in the index; must be
    76    defined as an attribute in the resource
    77  * `range_key` - (Required) The name of the range key; must be defined
    78  * `projection_type` - (Required) One of "ALL", "INCLUDE" or "KEYS_ONLY"
    79     where *ALL* projects every attribute into the index, *KEYS_ONLY*
    80      projects just the hash and range key into the index, and *INCLUDE*
    81      projects only the keys specified in the _non_key_attributes_
    82  parameter.
    83  * `non_key_attributes` - (Optional) Only required with *INCLUDE* as a
    84    projection type; a list of attributes to project into the index. These
    85  do not need to be defined as attributes on the table.
    86  
    87  For `global_secondary_index` objects only, you need to specify
    88  `write_capacity` and `read_capacity` in the same way you would for the
    89  table as they have separate I/O capacity.
    90  
    91  ### A note about attributes
    92  
    93  Only define attributes on the table object that are going to be used as:
    94  
    95  * Table hash key or range key
    96  * LSI or GSI hash key or range key
    97  
    98  The DynamoDB API expects attribute structure (name and type) to be
    99  passed along when creating or updating GSI/LSIs or creating the initial
   100  table. In these cases it expects the Hash / Range keys to be provided;
   101  because these get re-used in numerous places (i.e the table's range key
   102  could be a part of one or more GSIs), they are stored on the table
   103  object to prevent duplication and increase consistency. If you add
   104  attributes here that are not used in these scenarios it can cause an
   105  infinite loop in planning.  
   106  
   107  
   108  ## Attributes Reference
   109  
   110  The following attributes are exported:
   111  
   112  * `arn` - The arn of the table
   113  * `id` - The name of the table
   114