The CreateTable
operation adds a new table to your account. In an Amazon Web Services account, table names must be unique within each Region. That is, you can have two tables with same name if you create the tables in different Regions.
CreateTable
is an asynchronous operation. Upon receiving aCreateTable
request, DynamoDB immediately returns a response with aTableStatus
ofCREATING
. After the table is created, DynamoDB sets theTableStatus
toACTIVE
. You can perform read and write operations only on anACTIVE
table.
You can optionally define secondary indexes on the new table, as part of the CreateTable
operation. If you want to create multiple tables with secondary indexes on them, you must create the tables sequentially. Only one table with secondary indexes can be in the CREATING
state at any given time.
You can use the DescribeTable
action to check the table status.
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
create-table
--attribute-definitions <value>
--table-name <value>
--key-schema <value>
[--local-secondary-indexes <value>]
[--global-secondary-indexes <value>]
[--billing-mode <value>]
[--provisioned-throughput <value>]
[--stream-specification <value>]
[--sse-specification <value>]
[--tags <value>]
[--table-class <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--attribute-definitions
(list)
An array of attributes that describe the key schema for the table and indexes.
(structure)
Represents an attribute for describing the key schema for the table and indexes.
AttributeName -> (string)
A name for the attribute.
AttributeType -> (string)
The data type for the attribute, where:
S
- the attribute is of type String
N
- the attribute is of type Number
B
- the attribute is of type Binary
Shorthand Syntax:
AttributeName=string,AttributeType=string ...
JSON Syntax:
[
{
"AttributeName": "string",
"AttributeType": "S"|"N"|"B"
}
...
]
--table-name
(string)
The name of the table to create.
--key-schema
(list)
Specifies the attributes that make up the primary key for a table or an index. The attributes in
KeySchema
must also be defined in theAttributeDefinitions
array. For more information, see Data Model in the Amazon DynamoDB Developer Guide .Each
KeySchemaElement
in the array is composed of:
AttributeName
- The name of this key attribute.
KeyType
- The role that the key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from the DynamoDB usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
For a simple primary key (partition key), you must provide exactly one element with a
KeyType
ofHASH
.For a composite primary key (partition key and sort key), you must provide exactly two elements, in this order: The first element must have a
KeyType
ofHASH
, and the second element must have aKeyType
ofRANGE
.For more information, see Working with Tables in the Amazon DynamoDB Developer Guide .
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
Shorthand Syntax:
AttributeName=string,KeyType=string ...
JSON Syntax:
[
{
"AttributeName": "string",
"KeyType": "HASH"|"RANGE"
}
...
]
--local-secondary-indexes
(list)
One or more local secondary indexes (the maximum is 5) to be created on the table. Each index is scoped to a given partition key value. There is a 10 GB size limit per partition key value; otherwise, the size of a local secondary index is unconstrained.
Each local secondary index in the array includes the following:
IndexName
- The name of the local secondary index. Must be unique only for this table.
KeySchema
- Specifies the key schema for the local secondary index. The key schema must begin with the same partition key as the table.
Projection
- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:
ProjectionType
- One of the following:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- Only the specified table attributes are projected into the index. The list of projected attributes is inNonKeyAttributes
.
ALL
- All of the table attributes are projected into the index.
NonKeyAttributes
- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes
, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.(structure)
Represents the properties of a local secondary index.
IndexName -> (string)
The name of the local secondary index. The name must be unique among all other indexes on this table.
KeySchema -> (list)
The complete key schema for the local secondary index, consisting of one or more pairs of attribute names and key types:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
Projection -> (structure)
Represents attributes that are copied (projected) from the table into the local secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.
ProjectionType -> (string)
The set of attributes that are projected into the index:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- In addition to the attributes described inKEYS_ONLY
, the secondary index will include other non-key attributes that you specify.
ALL
- All of the table attributes are projected into the index.NonKeyAttributes -> (list)
Represents the non-key attribute names which will be projected into the index.
For local secondary indexes, the total count of
NonKeyAttributes
summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.(string)
Shorthand Syntax:
IndexName=string,KeySchema=[{AttributeName=string,KeyType=string},{AttributeName=string,KeyType=string}],Projection={ProjectionType=string,NonKeyAttributes=[string,string]} ...
JSON Syntax:
[
{
"IndexName": "string",
"KeySchema": [
{
"AttributeName": "string",
"KeyType": "HASH"|"RANGE"
}
...
],
"Projection": {
"ProjectionType": "ALL"|"KEYS_ONLY"|"INCLUDE",
"NonKeyAttributes": ["string", ...]
}
}
...
]
--global-secondary-indexes
(list)
One or more global secondary indexes (the maximum is 20) to be created on the table. Each global secondary index in the array includes the following:
IndexName
- The name of the global secondary index. Must be unique only for this table.
KeySchema
- Specifies the key schema for the global secondary index.
Projection
- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:
ProjectionType
- One of the following:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- Only the specified table attributes are projected into the index. The list of projected attributes is inNonKeyAttributes
.
ALL
- All of the table attributes are projected into the index.
NonKeyAttributes
- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes
, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.
ProvisionedThroughput
- The provisioned throughput settings for the global secondary index, consisting of read and write capacity units.(structure)
Represents the properties of a global secondary index.
IndexName -> (string)
The name of the global secondary index. The name must be unique among all other indexes on this table.
KeySchema -> (list)
The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
Projection -> (structure)
Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.
ProjectionType -> (string)
The set of attributes that are projected into the index:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- In addition to the attributes described inKEYS_ONLY
, the secondary index will include other non-key attributes that you specify.
ALL
- All of the table attributes are projected into the index.NonKeyAttributes -> (list)
Represents the non-key attribute names which will be projected into the index.
For local secondary indexes, the total count of
NonKeyAttributes
summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.(string)
ProvisionedThroughput -> (structure)
Represents the provisioned throughput settings for the specified global secondary index.
For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .
ReadCapacityUnits -> (long)
The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .If read/write capacity mode is
PAY_PER_REQUEST
the value is set to 0.WriteCapacityUnits -> (long)
The maximum number of writes consumed per second before DynamoDB returns a
ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .If read/write capacity mode is
PAY_PER_REQUEST
the value is set to 0.
Shorthand Syntax:
IndexName=string,KeySchema=[{AttributeName=string,KeyType=string},{AttributeName=string,KeyType=string}],Projection={ProjectionType=string,NonKeyAttributes=[string,string]},ProvisionedThroughput={ReadCapacityUnits=long,WriteCapacityUnits=long} ...
JSON Syntax:
[
{
"IndexName": "string",
"KeySchema": [
{
"AttributeName": "string",
"KeyType": "HASH"|"RANGE"
}
...
],
"Projection": {
"ProjectionType": "ALL"|"KEYS_ONLY"|"INCLUDE",
"NonKeyAttributes": ["string", ...]
},
"ProvisionedThroughput": {
"ReadCapacityUnits": long,
"WriteCapacityUnits": long
}
}
...
]
--billing-mode
(string)
Controls how you are charged for read and write throughput and how you manage capacity. This setting can be changed later.
PROVISIONED
- We recommend usingPROVISIONED
for predictable workloads.PROVISIONED
sets the billing mode to Provisioned Mode .
PAY_PER_REQUEST
- We recommend usingPAY_PER_REQUEST
for unpredictable workloads.PAY_PER_REQUEST
sets the billing mode to On-Demand Mode .Possible values:
PROVISIONED
PAY_PER_REQUEST
--provisioned-throughput
(structure)
Represents the provisioned throughput settings for a specified table or index. The settings can be modified using the
UpdateTable
operation.If you set BillingMode as
PROVISIONED
, you must specify this property. If you set BillingMode asPAY_PER_REQUEST
, you cannot specify this property.For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .
ReadCapacityUnits -> (long)
The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .If read/write capacity mode is
PAY_PER_REQUEST
the value is set to 0.WriteCapacityUnits -> (long)
The maximum number of writes consumed per second before DynamoDB returns a
ThrottlingException
. For more information, see Specifying Read and Write Requirements in the Amazon DynamoDB Developer Guide .If read/write capacity mode is
PAY_PER_REQUEST
the value is set to 0.
Shorthand Syntax:
ReadCapacityUnits=long,WriteCapacityUnits=long
JSON Syntax:
{
"ReadCapacityUnits": long,
"WriteCapacityUnits": long
}
--stream-specification
(structure)
The settings for DynamoDB Streams on the table. These settings consist of:
StreamEnabled
- Indicates whether DynamoDB Streams is to be enabled (true) or disabled (false).
StreamViewType
- When an item in the table is modified,StreamViewType
determines what information is written to the table’s stream. Valid values forStreamViewType
are:
KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.StreamEnabled -> (boolean)
Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
StreamViewType -> (string)
When an item in the table is modified,
StreamViewType
determines what information is written to the stream for this table. Valid values forStreamViewType
are:
KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.
Shorthand Syntax:
StreamEnabled=boolean,StreamViewType=string
JSON Syntax:
{
"StreamEnabled": true|false,
"StreamViewType": "NEW_IMAGE"|"OLD_IMAGE"|"NEW_AND_OLD_IMAGES"|"KEYS_ONLY"
}
--sse-specification
(structure)
Represents the settings used to enable server-side encryption.
Enabled -> (boolean)
Indicates whether server-side encryption is done using an Amazon Web Services managed key or an Amazon Web Services owned key. If enabled (true), server-side encryption type is set to
KMS
and an Amazon Web Services managed key is used (KMS charges apply). If disabled (false) or not specified, server-side encryption is set to Amazon Web Services owned key.SSEType -> (string)
Server-side encryption type. The only supported value is:
KMS
- Server-side encryption that uses Key Management Service. The key is stored in your account and is managed by KMS (KMS charges apply).KMSMasterKeyId -> (string)
The KMS key that should be used for the KMS encryption. To specify a key, use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. Note that you should only provide this parameter if the key is different from the default DynamoDB key
alias/aws/dynamodb
.
Shorthand Syntax:
Enabled=boolean,SSEType=string,KMSMasterKeyId=string
JSON Syntax:
{
"Enabled": true|false,
"SSEType": "AES256"|"KMS",
"KMSMasterKeyId": "string"
}
--tags
(list)
A list of key-value pairs to label the table. For more information, see Tagging for DynamoDB .
(structure)
Describes a tag. A tag is a key-value pair. You can add up to 50 tags to a single DynamoDB table.
Amazon Web Services-assigned tag names and values are automatically assigned the
aws:
prefix, which the user cannot assign. Amazon Web Services-assigned tag names do not count towards the tag limit of 50. User-assigned tag names have the prefixuser:
in the Cost Allocation Report. You cannot backdate the application of a tag.For an overview on tagging DynamoDB resources, see Tagging for DynamoDB in the Amazon DynamoDB Developer Guide .
Key -> (string)
The key of the tag. Tag keys are case sensitive. Each DynamoDB table can only have up to one tag with the same key. If you try to add an existing tag (same key), the existing tag value will be updated to the new value.
Value -> (string)
The value of the tag. Tag values are case-sensitive and can be null.
Shorthand Syntax:
Key=string,Value=string ...
JSON Syntax:
[
{
"Key": "string",
"Value": "string"
}
...
]
--table-class
(string)
The table class of the new table. Valid values are
STANDARD
andSTANDARD_INFREQUENT_ACCESS
.Possible values:
STANDARD
STANDARD_INFREQUENT_ACCESS
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
Example 1: To create a table with tags
The following create-table
example uses the specified attributes and key schema to create a table named MusicCollection
. This table uses provisioned throughput and is encrypted at rest using the default AWS owned CMK. The command also applies a tag to the table, with a key of Owner
and a value of blueTeam
.
aws dynamodb create-table \
--table-name MusicCollection \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--tags Key=Owner,Value=blueTeam
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "Artist",
"AttributeType": "S"
},
{
"AttributeName": "SongTitle",
"AttributeType": "S"
}
],
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"WriteCapacityUnits": 5,
"ReadCapacityUnits": 5
},
"TableSizeBytes": 0,
"TableName": "MusicCollection",
"TableStatus": "CREATING",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "Artist"
},
{
"KeyType": "RANGE",
"AttributeName": "SongTitle"
}
],
"ItemCount": 0,
"CreationDateTime": "2020-05-26T16:04:41.627000-07:00",
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 2: To create a table in On-Demand Mode
The following example creates a table called MusicCollection
using on-demand mode, rather than provisioned throughput mode. This is useful for tables with unpredictable workloads.
aws dynamodb create-table \
--table-name MusicCollection \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "Artist",
"AttributeType": "S"
},
{
"AttributeName": "SongTitle",
"AttributeType": "S"
}
],
"TableName": "MusicCollection",
"KeySchema": [
{
"AttributeName": "Artist",
"KeyType": "HASH"
},
{
"AttributeName": "SongTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-05-27T11:44:10.807000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 0,
"WriteCapacityUnits": 0
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"BillingModeSummary": {
"BillingMode": "PAY_PER_REQUEST"
}
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 3: To create a table and encrypt it with a Customer Managed CMK
The following example creates a table named MusicCollection
and encrypts it using a customer managed CMK.
aws dynamodb create-table \
--table-name MusicCollection \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--sse-specification Enabled=true,SSEType=KMS,KMSMasterKeyId=abcd1234-abcd-1234-a123-ab1234a1b234
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "Artist",
"AttributeType": "S"
},
{
"AttributeName": "SongTitle",
"AttributeType": "S"
}
],
"TableName": "MusicCollection",
"KeySchema": [
{
"AttributeName": "Artist",
"KeyType": "HASH"
},
{
"AttributeName": "SongTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-05-27T11:12:16.431000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"SSEDescription": {
"Status": "ENABLED",
"SSEType": "KMS",
"KMSMasterKeyArn": "arn:aws:kms:us-west-2:123456789012:key/abcd1234-abcd-1234-a123-ab1234a1b234"
}
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 4: To create a table with a Local Secondary Index
The following example uses the specified attributes and key schema to create a table named MusicCollection
with a Local Secondary Index named AlbumTitleIndex
.
aws dynamodb create-table \
--table-name MusicCollection \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S AttributeName=AlbumTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
--local-secondary-indexes \
"[
{
\"IndexName\": \"AlbumTitleIndex\",
\"KeySchema\": [
{\"AttributeName\": \"Artist\",\"KeyType\":\"HASH\"},
{\"AttributeName\": \"AlbumTitle\",\"KeyType\":\"RANGE\"}
],
\"Projection\": {
\"ProjectionType\": \"INCLUDE\",
\"NonKeyAttributes\": [\"Genre\", \"Year\"]
}
}
]"
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "AlbumTitle",
"AttributeType": "S"
},
{
"AttributeName": "Artist",
"AttributeType": "S"
},
{
"AttributeName": "SongTitle",
"AttributeType": "S"
}
],
"TableName": "MusicCollection",
"KeySchema": [
{
"AttributeName": "Artist",
"KeyType": "HASH"
},
{
"AttributeName": "SongTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-05-26T15:59:49.473000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"LocalSecondaryIndexes": [
{
"IndexName": "AlbumTitleIndex",
"KeySchema": [
{
"AttributeName": "Artist",
"KeyType": "HASH"
},
{
"AttributeName": "AlbumTitle",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "INCLUDE",
"NonKeyAttributes": [
"Genre",
"Year"
]
},
"IndexSizeBytes": 0,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection/index/AlbumTitleIndex"
}
]
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 5: To create a table with a Global Secondary Index
The following example creates a table named GameScores
with a Global Secondary Index called GameTitleIndex
. The base table has a partition key of UserId
and a sort key of GameTitle
, allowing you to find an individual user’s best score for a specific game efficiently, whereas the GSI has a partition key of GameTitle
and a sort key of TopScore
, allowing you to quickly find the overall highest score for a particular game.
aws dynamodb create-table \
--table-name GameScores \
--attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S AttributeName=TopScore,AttributeType=N \
--key-schema AttributeName=UserId,KeyType=HASH \
AttributeName=GameTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
--global-secondary-indexes \
"[
{
\"IndexName\": \"GameTitleIndex\",
\"KeySchema\": [
{\"AttributeName\":\"GameTitle\",\"KeyType\":\"HASH\"},
{\"AttributeName\":\"TopScore\",\"KeyType\":\"RANGE\"}
],
\"Projection\": {
\"ProjectionType\":\"INCLUDE\",
\"NonKeyAttributes\":[\"UserId\"]
},
\"ProvisionedThroughput\": {
\"ReadCapacityUnits\": 10,
\"WriteCapacityUnits\": 5
}
}
]"
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "GameTitle",
"AttributeType": "S"
},
{
"AttributeName": "TopScore",
"AttributeType": "N"
},
{
"AttributeName": "UserId",
"AttributeType": "S"
}
],
"TableName": "GameScores",
"KeySchema": [
{
"AttributeName": "UserId",
"KeyType": "HASH"
},
{
"AttributeName": "GameTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-05-26T17:28:15.602000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"GlobalSecondaryIndexes": [
{
"IndexName": "GameTitleIndex",
"KeySchema": [
{
"AttributeName": "GameTitle",
"KeyType": "HASH"
},
{
"AttributeName": "TopScore",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "INCLUDE",
"NonKeyAttributes": [
"UserId"
]
},
"IndexStatus": "CREATING",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"IndexSizeBytes": 0,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameTitleIndex"
}
]
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 6: To create a table with multiple Global Secondary Indexes at once
The following example creates a table named GameScores
with two Global Secondary Indexes. The GSI schemas are passed via a file, rather than on the command line.
aws dynamodb create-table \
--table-name GameScores \
--attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S AttributeName=TopScore,AttributeType=N AttributeName=Date,AttributeType=S \
--key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
--global-secondary-indexes file://gsi.json
Contents of gsi.json
:
[
{
"IndexName": "GameTitleIndex",
"KeySchema": [
{
"AttributeName": "GameTitle",
"KeyType": "HASH"
},
{
"AttributeName": "TopScore",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
}
},
{
"IndexName": "GameDateIndex",
"KeySchema": [
{
"AttributeName": "GameTitle",
"KeyType": "HASH"
},
{
"AttributeName": "Date",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
}
}
]
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "Date",
"AttributeType": "S"
},
{
"AttributeName": "GameTitle",
"AttributeType": "S"
},
{
"AttributeName": "TopScore",
"AttributeType": "N"
},
{
"AttributeName": "UserId",
"AttributeType": "S"
}
],
"TableName": "GameScores",
"KeySchema": [
{
"AttributeName": "UserId",
"KeyType": "HASH"
},
{
"AttributeName": "GameTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-08-04T16:40:55.524000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"GlobalSecondaryIndexes": [
{
"IndexName": "GameTitleIndex",
"KeySchema": [
{
"AttributeName": "GameTitle",
"KeyType": "HASH"
},
{
"AttributeName": "TopScore",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "CREATING",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"IndexSizeBytes": 0,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameTitleIndex"
},
{
"IndexName": "GameDateIndex",
"KeySchema": [
{
"AttributeName": "GameTitle",
"KeyType": "HASH"
},
{
"AttributeName": "Date",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"IndexStatus": "CREATING",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
},
"IndexSizeBytes": 0,
"ItemCount": 0,
"IndexArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/index/GameDateIndex"
}
]
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
Example 7: To create a table with Streams enabled
The following example creates a table called GameScores
with DynamoDB Streams enabled. Both new and old images of each item will be written to the stream.
aws dynamodb create-table \
--table-name GameScores \
--attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=GameTitle,AttributeType=S \
--key-schema AttributeName=UserId,KeyType=HASH AttributeName=GameTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=TRUE,StreamViewType=NEW_AND_OLD_IMAGES
Output:
{
"TableDescription": {
"AttributeDefinitions": [
{
"AttributeName": "GameTitle",
"AttributeType": "S"
},
{
"AttributeName": "UserId",
"AttributeType": "S"
}
],
"TableName": "GameScores",
"KeySchema": [
{
"AttributeName": "UserId",
"KeyType": "HASH"
},
{
"AttributeName": "GameTitle",
"KeyType": "RANGE"
}
],
"TableStatus": "CREATING",
"CreationDateTime": "2020-05-27T10:49:34.056000-07:00",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 5
},
"TableSizeBytes": 0,
"ItemCount": 0,
"TableArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores",
"TableId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"StreamSpecification": {
"StreamEnabled": true,
"StreamViewType": "NEW_AND_OLD_IMAGES"
},
"LatestStreamLabel": "2020-05-27T17:49:34.056",
"LatestStreamArn": "arn:aws:dynamodb:us-west-2:123456789012:table/GameScores/stream/2020-05-27T17:49:34.056"
}
}
For more information, see Basic Operations for Tables in the Amazon DynamoDB Developer Guide.
TableDescription -> (structure)
Represents the properties of the table.
AttributeDefinitions -> (list)
An array of
AttributeDefinition
objects. Each of these objects describes one attribute in the table and index key schema.Each
AttributeDefinition
object in this array is composed of:
AttributeName
- The name of the attribute.
AttributeType
- The data type for the attribute.(structure)
Represents an attribute for describing the key schema for the table and indexes.
AttributeName -> (string)
A name for the attribute.
AttributeType -> (string)
The data type for the attribute, where:
S
- the attribute is of type String
N
- the attribute is of type Number
B
- the attribute is of type BinaryTableName -> (string)
The name of the table.
KeySchema -> (list)
The primary key structure for the table. Each
KeySchemaElement
consists of:
AttributeName
- The name of the attribute.
KeyType
- The role of the attribute:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
For more information about primary keys, see Primary Key in the Amazon DynamoDB Developer Guide .
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
TableStatus -> (string)
The current state of the table:
CREATING
- The table is being created.
UPDATING
- The table is being updated.
DELETING
- The table is being deleted.
ACTIVE
- The table is ready for use.
INACCESSIBLE_ENCRYPTION_CREDENTIALS
- The KMS key used to encrypt the table in inaccessible. Table operations may fail due to failure to use the KMS key. DynamoDB will initiate the table archival process when a table’s KMS key remains inaccessible for more than seven days.
ARCHIVING
- The table is being archived. Operations are not allowed until archival is complete.
ARCHIVED
- The table has been archived. See the ArchivalReason for more information.CreationDateTime -> (timestamp)
The date and time when the table was created, in UNIX epoch time format.
ProvisionedThroughput -> (structure)
The provisioned throughput settings for the table, consisting of read and write capacity units, along with data about increases and decreases.
LastIncreaseDateTime -> (timestamp)
The date and time of the last provisioned throughput increase for this table.
LastDecreaseDateTime -> (timestamp)
The date and time of the last provisioned throughput decrease for this table.
NumberOfDecreasesToday -> (long)
The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums on provisioned throughput decreases, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .
ReadCapacityUnits -> (long)
The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
ThrottlingException
. Eventually consistent reads require less effort than strongly consistent reads, so a setting of 50ReadCapacityUnits
per second provides 100 eventually consistentReadCapacityUnits
per second.WriteCapacityUnits -> (long)
The maximum number of writes consumed per second before DynamoDB returns a
ThrottlingException
.TableSizeBytes -> (long)
The total size of the specified table, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
ItemCount -> (long)
The number of items in the specified table. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
TableArn -> (string)
The Amazon Resource Name (ARN) that uniquely identifies the table.
TableId -> (string)
Unique identifier for the table for which the backup was created.
BillingModeSummary -> (structure)
Contains the details for the read/write capacity mode.
BillingMode -> (string)
Controls how you are charged for read and write throughput and how you manage capacity. This setting can be changed later.
PROVISIONED
- Sets the read/write capacity mode toPROVISIONED
. We recommend usingPROVISIONED
for predictable workloads.
PAY_PER_REQUEST
- Sets the read/write capacity mode toPAY_PER_REQUEST
. We recommend usingPAY_PER_REQUEST
for unpredictable workloads.LastUpdateToPayPerRequestDateTime -> (timestamp)
Represents the time when
PAY_PER_REQUEST
was last set as the read/write capacity mode.LocalSecondaryIndexes -> (list)
Represents one or more local secondary indexes on the table. Each index is scoped to a given partition key value. Tables with one or more local secondary indexes are subject to an item collection size limit, where the amount of data within a given item collection cannot exceed 10 GB. Each element is composed of:
IndexName
- The name of the local secondary index.
KeySchema
- Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.
Projection
- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:
ProjectionType
- One of the following:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- Only the specified table attributes are projected into the index. The list of projected attributes is inNonKeyAttributes
.
ALL
- All of the table attributes are projected into the index.
NonKeyAttributes
- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes
, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.
IndexSizeBytes
- Represents the total size of the index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
ItemCount
- Represents the number of items in the index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.If the table is in the
DELETING
state, no information about indexes will be returned.(structure)
Represents the properties of a local secondary index.
IndexName -> (string)
Represents the name of the local secondary index.
KeySchema -> (list)
The complete key schema for the local secondary index, consisting of one or more pairs of attribute names and key types:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
Projection -> (structure)
Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.
ProjectionType -> (string)
The set of attributes that are projected into the index:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- In addition to the attributes described inKEYS_ONLY
, the secondary index will include other non-key attributes that you specify.
ALL
- All of the table attributes are projected into the index.NonKeyAttributes -> (list)
Represents the non-key attribute names which will be projected into the index.
For local secondary indexes, the total count of
NonKeyAttributes
summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.(string)
IndexSizeBytes -> (long)
The total size of the specified index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
ItemCount -> (long)
The number of items in the specified index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
IndexArn -> (string)
The Amazon Resource Name (ARN) that uniquely identifies the index.
GlobalSecondaryIndexes -> (list)
The global secondary indexes, if any, on the table. Each index is scoped to a given partition key value. Each element is composed of:
Backfilling
- If true, then the index is currently in the backfilling phase. Backfilling occurs only when a new global secondary index is added to the table. It is the process by which DynamoDB populates the new index with data from the table. (This attribute does not appear for indexes that were created during aCreateTable
operation.) You can delete an index that is being created during theBackfilling
phase whenIndexStatus
is set to CREATING andBackfilling
is true. You can’t delete the index that is being created whenIndexStatus
is set to CREATING andBackfilling
is false. (This attribute does not appear for indexes that were created during aCreateTable
operation.)
IndexName
- The name of the global secondary index.
IndexSizeBytes
- The total size of the global secondary index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
IndexStatus
- The current status of the global secondary index:
CREATING
- The index is being created.
UPDATING
- The index is being updated.
DELETING
- The index is being deleted.
ACTIVE
- The index is ready for use.
ItemCount
- The number of items in the global secondary index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
KeySchema
- Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.
Projection
- Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:
ProjectionType
- One of the following:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- In addition to the attributes described inKEYS_ONLY
, the secondary index will include other non-key attributes that you specify.
ALL
- All of the table attributes are projected into the index.
NonKeyAttributes
- A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided inNonKeyAttributes
, summed across all of the secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.
ProvisionedThroughput
- The provisioned throughput settings for the global secondary index, consisting of read and write capacity units, along with data about increases and decreases.If the table is in the
DELETING
state, no information about indexes will be returned.(structure)
Represents the properties of a global secondary index.
IndexName -> (string)
The name of the global secondary index.
KeySchema -> (list)
The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
(structure)
Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.
A
KeySchemaElement
represents exactly one attribute of the primary key. For example, a simple primary key would be represented by oneKeySchemaElement
(for the partition key). A composite primary key would require oneKeySchemaElement
for the partition key, and anotherKeySchemaElement
for the sort key.A
KeySchemaElement
must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.AttributeName -> (string)
The name of a key attribute.
KeyType -> (string)
The role that this key attribute will assume:
HASH
- partition key
RANGE
- sort keyNote
The partition key of an item is also known as its hash attribute . The term “hash attribute” derives from DynamoDB’s usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute . The term “range attribute” derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
Projection -> (structure)
Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.
ProjectionType -> (string)
The set of attributes that are projected into the index:
KEYS_ONLY
- Only the index and primary keys are projected into the index.
INCLUDE
- In addition to the attributes described inKEYS_ONLY
, the secondary index will include other non-key attributes that you specify.
ALL
- All of the table attributes are projected into the index.NonKeyAttributes -> (list)
Represents the non-key attribute names which will be projected into the index.
For local secondary indexes, the total count of
NonKeyAttributes
summed across all of the local secondary indexes, must not exceed 100. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.(string)
IndexStatus -> (string)
The current state of the global secondary index:
CREATING
- The index is being created.
UPDATING
- The index is being updated.
DELETING
- The index is being deleted.
ACTIVE
- The index is ready for use.Backfilling -> (boolean)
Indicates whether the index is currently backfilling. Backfilling is the process of reading items from the table and determining whether they can be added to the index. (Not all items will qualify: For example, a partition key cannot have any duplicate values.) If an item can be added to the index, DynamoDB will do so. After all items have been processed, the backfilling operation is complete and
Backfilling
is false.You can delete an index that is being created during the
Backfilling
phase whenIndexStatus
is set to CREATING andBackfilling
is true. You can’t delete the index that is being created whenIndexStatus
is set to CREATING andBackfilling
is false.Note
For indexes that were created during a
CreateTable
operation, theBackfilling
attribute does not appear in theDescribeTable
output.ProvisionedThroughput -> (structure)
Represents the provisioned throughput settings for the specified global secondary index.
For current minimum and maximum provisioned throughput values, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .
LastIncreaseDateTime -> (timestamp)
The date and time of the last provisioned throughput increase for this table.
LastDecreaseDateTime -> (timestamp)
The date and time of the last provisioned throughput decrease for this table.
NumberOfDecreasesToday -> (long)
The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums on provisioned throughput decreases, see Service, Account, and Table Quotas in the Amazon DynamoDB Developer Guide .
ReadCapacityUnits -> (long)
The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
ThrottlingException
. Eventually consistent reads require less effort than strongly consistent reads, so a setting of 50ReadCapacityUnits
per second provides 100 eventually consistentReadCapacityUnits
per second.WriteCapacityUnits -> (long)
The maximum number of writes consumed per second before DynamoDB returns a
ThrottlingException
.IndexSizeBytes -> (long)
The total size of the specified index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
ItemCount -> (long)
The number of items in the specified index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.
IndexArn -> (string)
The Amazon Resource Name (ARN) that uniquely identifies the index.
StreamSpecification -> (structure)
The current DynamoDB Streams configuration for the table.
StreamEnabled -> (boolean)
Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.
StreamViewType -> (string)
When an item in the table is modified,
StreamViewType
determines what information is written to the stream for this table. Valid values forStreamViewType
are:
KEYS_ONLY
- Only the key attributes of the modified item are written to the stream.
NEW_IMAGE
- The entire item, as it appears after it was modified, is written to the stream.
OLD_IMAGE
- The entire item, as it appeared before it was modified, is written to the stream.
NEW_AND_OLD_IMAGES
- Both the new and the old item images of the item are written to the stream.LatestStreamLabel -> (string)
A timestamp, in ISO 8601 format, for this stream.
Note that
LatestStreamLabel
is not a unique identifier for the stream, because it is possible that a stream from another table might have the same timestamp. However, the combination of the following three elements is guaranteed to be unique:
Amazon Web Services customer ID
Table name
StreamLabel
LatestStreamArn -> (string)
The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table.
GlobalTableVersion -> (string)
Represents the version of global tables in use, if the table is replicated across Amazon Web Services Regions.
Replicas -> (list)
Represents replicas of the table.
(structure)
Contains the details of the replica.
RegionName -> (string)
The name of the Region.
ReplicaStatus -> (string)
The current state of the replica:
CREATING
- The replica is being created.
UPDATING
- The replica is being updated.
DELETING
- The replica is being deleted.
ACTIVE
- The replica is ready for use.
REGION_DISABLED
- The replica is inaccessible because the Amazon Web Services Region has been disabled.Note
If the Amazon Web Services Region remains inaccessible for more than 20 hours, DynamoDB will remove this replica from the replication group. The replica will not be deleted and replication will stop from and to this region.
INACCESSIBLE_ENCRYPTION_CREDENTIALS
- The KMS key used to encrypt the table is inaccessible.Note
If the KMS key remains inaccessible for more than 20 hours, DynamoDB will remove this replica from the replication group. The replica will not be deleted and replication will stop from and to this region.
ReplicaStatusDescription -> (string)
Detailed information about the replica status.
ReplicaStatusPercentProgress -> (string)
Specifies the progress of a Create, Update, or Delete action on the replica as a percentage.
KMSMasterKeyId -> (string)
The KMS key of the replica that will be used for KMS encryption.
ProvisionedThroughputOverride -> (structure)
Replica-specific provisioned throughput. If not described, uses the source table’s provisioned throughput settings.
ReadCapacityUnits -> (long)
Replica-specific read capacity units. If not specified, uses the source table’s read capacity settings.
GlobalSecondaryIndexes -> (list)
Replica-specific global secondary index settings.
(structure)
Represents the properties of a replica global secondary index.
IndexName -> (string)
The name of the global secondary index.
ProvisionedThroughputOverride -> (structure)
If not described, uses the source table GSI’s read capacity settings.
ReadCapacityUnits -> (long)
Replica-specific read capacity units. If not specified, uses the source table’s read capacity settings.
ReplicaInaccessibleDateTime -> (timestamp)
The time at which the replica was first detected as inaccessible. To determine cause of inaccessibility check the
ReplicaStatus
property.ReplicaTableClassSummary -> (structure)
Contains details of the table class.
TableClass -> (string)
The table class of the specified table. Valid values are
STANDARD
andSTANDARD_INFREQUENT_ACCESS
.LastUpdateDateTime -> (timestamp)
The date and time at which the table class was last updated.
RestoreSummary -> (structure)
Contains details for the restore.
SourceBackupArn -> (string)
The Amazon Resource Name (ARN) of the backup from which the table was restored.
SourceTableArn -> (string)
The ARN of the source table of the backup that is being restored.
RestoreDateTime -> (timestamp)
Point in time or source backup time.
RestoreInProgress -> (boolean)
Indicates if a restore is in progress or not.
SSEDescription -> (structure)
The description of the server-side encryption status on the specified table.
Status -> (string)
Represents the current state of server-side encryption. The only supported values are:
ENABLED
- Server-side encryption is enabled.
UPDATING
- Server-side encryption is being updated.SSEType -> (string)
Server-side encryption type. The only supported value is:
KMS
- Server-side encryption that uses Key Management Service. The key is stored in your account and is managed by KMS (KMS charges apply).KMSMasterKeyArn -> (string)
The KMS key ARN used for the KMS encryption.
InaccessibleEncryptionDateTime -> (timestamp)
Indicates the time, in UNIX epoch date format, when DynamoDB detected that the table’s KMS key was inaccessible. This attribute will automatically be cleared when DynamoDB detects that the table’s KMS key is accessible again. DynamoDB will initiate the table archival process when table’s KMS key remains inaccessible for more than seven days from this date.
ArchivalSummary -> (structure)
Contains information about the table archive.
ArchivalDateTime -> (timestamp)
The date and time when table archival was initiated by DynamoDB, in UNIX epoch time format.
ArchivalReason -> (string)
The reason DynamoDB archived the table. Currently, the only possible value is:
INACCESSIBLE_ENCRYPTION_CREDENTIALS
- The table was archived due to the table’s KMS key being inaccessible for more than seven days. An On-Demand backup was created at the archival time.ArchivalBackupArn -> (string)
The Amazon Resource Name (ARN) of the backup the table was archived to, when applicable in the archival reason. If you wish to restore this backup to the same table name, you will need to delete the original table.
TableClassSummary -> (structure)
Contains details of the table class.
TableClass -> (string)
The table class of the specified table. Valid values are
STANDARD
andSTANDARD_INFREQUENT_ACCESS
.LastUpdateDateTime -> (timestamp)
The date and time at which the table class was last updated.