Tutorial: Creating MRSC global tables in DynamoDB
Note
Multi-Region strong consistency (MRSC) is available in preview and is subject to change.
In preview, a global table with MRSC must contain exactly three replicas in the supported Regions. You create an MRSC global table by adding two replica tables to a single-Region DynamoDB table that doesn't contain any data, and doesn't have any unsupported features configured.
- Using the AWS Management Console
-
This console procedure creates an MRSC global table by creating a new single-Region table. This procedure also adds two replica tables in the remaining supported preview Regions.
-
Sign in to the AWS Management Console and open the DynamoDB console at https://console.aws.amazon.com/dynamodb/
. -
From the top navigation pane, choose the Region where global tables with MRSC is supported. For example, choose
us-east-2
. -
Create a new on-demand, single-Region table. For information about creating a table, see AWS Management Console in Step 1: Create a table in DynamoDB.
Note
It might take a few minutes for the newly created table to change to the ACTIVE state.
-
On the Tables page, choose your newly created table.
-
Choose the Global tables tab, then choose Create replica.
-
On the Create replica page, do the following:
-
Under Multi-Region Consistency, choose Strong consistency.
-
Choose Create replicas.
Note
It might take a few minutes for the new replica tables to appear and change to the ACTIVE state.
-
-
- Using the AWS CLI
-
This AWS CLI procedure creates an MRSC global table by creating a new single-Region table, and then adding two replica tables.
-
Create a new on-demand, single-Region table named
MusicTable
in the us-east-2 Region.aws dynamodb create-table \ --table-name MusicTable \ --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 \ --region us-east-2
-
Verify that the new table has been created and is in the ACTIVE state.
Note
It might take a few minutes for the table to change to the ACTIVE state.
aws dynamodb describe-table \ --table-name MusicTable \ --region us-east-2 { "Table": { ... "TableStatus": "ACTIVE", ... }
-
Add two new replica tables to the single-Region table in the remaining supported Regions for preview by specifying the
multi-region-consistency
parameter toSTRONG
.aws dynamodb update-table \ --table-name MusicTable \ --replica-updates '[{"Create": {"RegionName": "us-east-1"}}, {"Create": {"RegionName": "us-west-2"}}]' \ --multi-region-consistency STRONG \ --region us-east-2
-
Use the describe-table
command to verify that the two new replicas have been created and are in the ACTIVE state, and that the global table is configured for multi-Region strong consistency. aws dynamodb describe-table \ --table-name MusicTable \ --region us-east-1 { "Table": { ... "Replicas": [ { "RegionName": "us-east-1", "ReplicaStatus": "ACTIVE" }, { "RegionName": "us-west-2", "ReplicaStatus": "ACTIVE" } ], "MultiRegionConsistency": "STRONG" ... }
-