Skip to content

Instantly share code, notes, and snippets.

@adhorn
Created May 3, 2018 11:45
Show Gist options
  • Select an option

  • Save adhorn/331c85bdc25cd767e1c7a3f7c68de3f5 to your computer and use it in GitHub Desktop.

Select an option

Save adhorn/331c85bdc25cd767e1c7a3f7c68de3f5 to your computer and use it in GitHub Desktop.
#create the initial table with stream enabled in us-east-1
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 us-east-1
# create identical table with stream enable in us-west-2
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 us-west-2
# create a global table consisting of replica tables previously created.
aws dynamodb create-global-table \
--global-table-name MyGlobalTable \
--replication-group RegionName=us-west-2 RegionName=us-east-1 \
--region us-east-1
# This should output the following
{
"GlobalTableDescription": {
"GlobalTableStatus": "CREATING",
"GlobalTableName": "MyGlobalTable",
"ReplicationGroup": [
{
"RegionName": "us-east-1"
},
{
"RegionName": "us-west-2"
}
],
"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