Skip to content

Instantly share code, notes, and snippets.

@adhorn
Created April 24, 2018 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adhorn/997496feec26f217011e085a0f9fbc5c to your computer and use it in GitHub Desktop.
Save adhorn/997496feec26f217011e085a0f9fbc5c to your computer and use it in GitHub Desktop.
Create DynamoDB Global Tables
#create the initial table with stream enabled (here in Ireland)
aws dynamodb create-table \
--table-name MyGlobalTable \
--attribute-definitions \
AttributeName=item_id,AttributeType=S \
--key-schema \
AttributeName=item_id,KeyType=HASH \
--provisioned-throughput \
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
--region eu-west-1
# create identical table with stream enable in another region (here Frankfurt)
aws dynamodb create-table \
--table-name MyGlobalTable \
--attribute-definitions \
AttributeName=item_id,AttributeType=S \
--key-schema \
AttributeName=item_id,KeyType=HASH \
--provisioned-throughput \
ReadCapacityUnits=5,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
--region eu-west-1
# create a global table consisting of replica tables previously created.
aws dynamodb create-global-table \
--global-table-name MyGlobalTable \
--replication-group RegionName=eu-west-1 RegionName=eu-central-1 \
--region eu-west-1
# This should output the following
{
"GlobalTableDescription": {
"GlobalTableStatus": "CREATING",
"GlobalTableName": "MyGlobalTable",
"ReplicationGroup": [
{
"RegionName": "eu-central-1"
},
{
"RegionName": "eu-west-1"
}
],
"CreationDateTime": 1524553979.752,
"GlobalTableArn": "arn:aws:dynamodb::xxxxxxxxx:global-table/MyGlobalTable"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment