Global tables replicate a table across AWS regions, multi-active: every replica accepts reads and writes. Replication is typically under a second, asynchronous, and conflicts are resolved last writer wins by timestamp.
That conflict rule needs stating plainly, because it is the design constraint. If the same item is written in two regions at nearly the same time, one write is silently discarded. There is no conflict record, no notification and no merge. Global tables are therefore right when writes to a given item are naturally confined to one region - region-affinity per user or per tenant - and wrong when two regions genuinely contend for the same item. Note also: every replicated write is billed again in the destination region, and you cannot add a replica to a table with existing items without a brief process.
Point-in-time recovery keeps continuous backups for 35 days and restores to any second in that window. It must be enabled in advance, it costs storage per GB-month, and it is the mechanism that recovers you from a bad deployment - the realistic DynamoDB incident. A PITR restore creates a new table: it does not restore in place, so your runbook needs a cutover step, and the restored table comes without its auto scaling settings, TTL configuration, stream settings or tags, which must be reapplied. That is a trap worth knowing before the incident.
On-demand backups are full snapshots, created instantly with no capacity consumption, retained until deleted, and also restored to a new table. AWS Backup integration adds cross-region and cross-account copies and lifecycle policies.
Export to S3 writes the table in DynamoDB JSON or Ion format without consuming capacity, from any point in the PITR window, and incremental exports cover a time range. This is how you get the data to Athena, Glue or a warehouse - the right answer to analytics over DynamoDB, which is not a Scan.
TTL deletes items after an epoch-seconds timestamp in a named attribute. It is free - it consumes no write capacity - and deletions appear in Streams, so you can archive on expiry. The two things to know: expiry is not prompt, typically within 48 hours of the timestamp, so an expired item can still be returned by a query and your application must filter on it; and the attribute must be a Number holding epoch seconds, not milliseconds and not a string, which is the most common TTL misconfiguration and fails silently.
Verifying a recovery means running assertions, not observing that the table exists. Item counts, aggregate checks and your capstone invariants - and note that DescribeTable's ItemCount is updated roughly every six hours and is therefore useless immediately after a restore.
Laboratory exercise 5 - break it, then get it back.
Enable PITR and create an on-demand backup.
Perform a destructive mistake at a recorded time - a script that deletes or corrupts a large number of items, which is the realistic incident. Then recover three ways and compare: a PITR restore to a point before it, a restore from the on-demand backup, and a rebuild from an S3 export. Time each and record RPO and RTO.
Then demonstrate the restore trap: configure auto scaling, TTL, Streams and tags on the source table, restore it, and enumerate exactly what came back and what did not. Write the reapplication into the runbook.
Configure TTL. Demonstrate the delay by setting a timestamp in the past and recording how long until the item actually disappears, and show the expired-but-present item being returned by a query in the meantime.
For global tables, add a replica in a second region. Measure replication lag. Then write the same item in both regions simultaneously and show one write silently discarded. If a second region is impractical, produce a design exercise: topology, region affinity strategy, the conflict consequence, the doubled write cost, and the runbook.
Deliverable: the recovery runbook, measured RPO and RTO for all three methods, the enumerated restore trap with the reapplication steps, the TTL delay measurement with the stale-read evidence, the global table lag and the discarded-write demonstration, and verification by assertions.
// ================= POINT-IN-TIME RECOVERY ==========================
// MUST BE ENABLED IN ADVANCE. 35 days, any second. The mechanism that
// recovers you from a BAD DEPLOYMENT - the realistic DynamoDB
// incident. Turn it on when you create the table.
// aws dynamodb update-continuous-backups --table-name Commerce \
// --point-in-time-recovery-specification \
// PointInTimeRecoveryEnabled=true
//
// aws dynamodb describe-continuous-backups --table-name Commerce
// -> EarliestRestorableDateTime / LatestRestorableDateTime
//
// aws dynamodb restore-table-to-point-in-time \
// --source-table-name Commerce \
// --target-table-name Commerce-recovered \
// --restore-date-time 2026-11-30T14:04:00Z
//
// IT RESTORES TO A NEW TABLE. Not in place. Your runbook needs a
// CUTOVER step - repoint the application, or rename via a new deploy.
// ================= THE RESTORE TRAP ================================
// A restored table comes WITHOUT:
// * auto scaling settings
// * TTL configuration
// * stream settings (and therefore every stream consumer)
// * tags
// * IAM resource policies
// * Contributor Insights
// * (optionally) the secondary indexes, unless you ask for them
//
// So a restore that "worked" can leave you with no TTL expiring
// items, no streams maintaining your denormalised copies, and no auto
// scaling. ENUMERATE IT IN THE LAB and write the reapplication into
// the runbook, in order:
// 1. restore
// 2. reapply TTL update-time-to-live
// 3. reapply streams update-table --stream-specification
// 4. recreate consumers (and set their starting position!)
// 5. reapply auto scaling register-scalable-target + policy
// 6. reapply tags tag-resource
// 7. VERIFY with assertions
// 8. cut over
// ================= On-demand backups and export ====================
// aws dynamodb create-backup --table-name Commerce \
// --backup-name commerce-20261130
// -- instant, consumes NO capacity, retained until deleted
// aws dynamodb restore-table-from-backup \
// --target-table-name Commerce-restored --backup-arn arn:...
// aws dynamodb export-table-to-point-in-time \
// --table-arn arn:aws:dynamodb:eu-west-2:...:table/Commerce \
// --s3-bucket my-exports --export-format DYNAMODB_JSON \
// --export-time 2026-11-30T14:00:00Z
// -- consumes NO capacity. THIS is how you do analytics over
// DynamoDB: export to S3, then Athena or Glue. NOT a Scan.
// -- incremental exports cover a time range.
// ================= TTL: free, and NOT PROMPT =======================
// aws dynamodb update-time-to-live --table-name Commerce \
// --time-to-live-specification Enabled=true,AttributeName=ttl
await db.send(new PutCommand({ TableName: "Commerce", Item: {
PK: "SESSION#abc123", SK: "META", userId: "u-1234",
// A NUMBER, in epoch SECONDS. Not milliseconds. Not a string.
// This is the commonest TTL misconfiguration AND IT FAILS
// SILENTLY - no error, items simply never expire.
ttl: Math.floor(Date.now() / 1000) + 1800
}}));
// EXPIRY IS NOT PROMPT - typically within 48 HOURS of the timestamp.
// SO AN EXPIRED ITEM CAN STILL BE RETURNED, and your application
// MUST FILTER ON IT:
const now = Math.floor(Date.now() / 1000);
await db.send(new QueryCommand({
TableName: "Commerce",
KeyConditionExpression: "PK = :pk",
FilterExpression: "attribute_not_exists(#ttl) OR #ttl > :now",
ExpressionAttributeNames: { "#ttl": "ttl" },
ExpressionAttributeValues: { ":pk": "SESSION#abc123", ":now": now }
}));
// Measure the actual delay in the lab. It is longer than people
// expect, and a business rule built on prompt expiry is broken.
//
// TTL deletions DO appear in Streams (userIdentity principalId
// "dynamodb.amazonaws.com"), so you can archive on expiry - which
// is a genuinely useful pattern.
// ================= GLOBAL TABLES: LAST WRITER WINS =================
// aws dynamodb update-table --table-name Commerce \
// --replica-updates '[{"Create": {"RegionName": "us-east-1"}}]'
// aws dynamodb describe-table --table-name Commerce \
// --query 'Table.Replicas'
//
// Multi-active: EVERY replica accepts reads and writes. Replication
// typically under a second, asynchronous.
//
// CONFLICTS ARE RESOLVED LAST WRITER WINS BY TIMESTAMP.
//
// the same item written in eu-west-2 and us-east-1 at nearly the
// same moment -> ONE WRITE IS SILENTLY DISCARDED
// no conflict record. no notification. no merge.
//
// So global tables are RIGHT when writes to a given item are
// naturally confined to one region - region affinity per user or per
// tenant - and WRONG when two regions genuinely contend for the same
// item. Demonstrate the discarded write; it is more convincing than
// the warning.
//
// Also: EVERY REPLICATED WRITE IS BILLED AGAIN in the destination
// region (as replicated WCUs), plus cross-region data transfer.
// CloudWatch: ReplicationLatency, PendingReplicationCount.
// ================= VERIFY WITH ASSERTIONS ==========================
// "The table exists and is ACTIVE" is NOT verification.
// aws dynamodb describe-table --table-name Commerce-recovered \
// --query 'Table.ItemCount'
// ^^ UPDATED ROUGHLY EVERY SIX HOURS. Useless right after a
// restore. Count properly:
let total = 0, k;
do {
const p = await db.send(new ScanCommand({
TableName: "Commerce-recovered", Select: "COUNT", ExclusiveStartKey: k }));
total += p.Count; k = p.LastEvaluatedKey;
} while (k);
// ... then run the capstone invariants.
Open this example in the editor and change it. Nothing you type is saved.
Discussion
No questions on this topic yet. Sign in to ask the first one.