DynamoDB
Get started with Amazon DynamoDB on LocalStack
2 minute read
DynamoDB on LocalStack is powered by DynamoDB Local.
Global tables
LocalStack has support for global tables (version 2019). These are tables belonging to the same account and replicated across different regions.
Following example illustrates the use of global tables:
# Create a table
$ awslocal dynamodb create-table \
--table-name global01 \
--key-schema AttributeName=id,KeyType=HASH \
--attribute-definitions AttributeName=id,AttributeType=S \
--billing-mode PAY_PER_REQUEST \
--region ap-south-1
# Create replicas
$ awslocal dynamodb update-table \
--table-name global01 \
--replica-updates '[{"Create": {"RegionName": "eu-central-1"}}, {"Create": {"RegionName": "us-west-1"}}]' \
--region ap-south-1
# Table can be operated on in all replicated regions
$ awslocal dynamodb list-tables --region eu-central-1
{
"TableNames": [
"global01"
]
}
$ awslocal dynamodb put-item --table-name global01 --item '{"id":{"S":"foo"}}' --region eu-central-1
$ awslocal dynamodb describe-table --table-name global01 --query 'Table.ItemCount' --region ap-south-1
1
Warning
When describing global tables, the current table is treated as a replica. This is a known bug https://github.com/localstack/localstack/issues/7426.$ awslocal dynamodb describe-table --table-name global01 --query 'Table.Replicas' --region us-west-1
[
{
"RegionName": "ap-south-1",
"ReplicaStatus": "ACTIVE"
},
{
"RegionName": "eu-central-1",
"ReplicaStatus": "ACTIVE"
},
{
"RegionName": "us-west-1",
"ReplicaStatus": "ACTIVE"
}
]
Warning
It is currently not possible to remove the original table region from the replication set. Deleting the original table will also remove all the replicas.Warning
DynamoDB Streams are only supported for original tables and not for replicated tables. Please see https://github.com/localstack/localstack/issues/7405 for more information.Warning
Batch operations (BatchWriteItem
, BatchGetItem
, etc.) are currently not supported on replicated tables.Last modified June 5, 2023: Add missing quote (#656) (b9ddb6f23)