You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# DynamoDB Global Table with Multi-Region Strong Consistency
2
+
3
+
This example demonstrates how to create a DynamoDB Global Table with `MultiRegionConsistency: STRONG` using AWS CDK and a CloudFormation L1 override. The implementation supports JSON configuration for multi-region deployment with witness region capabilities.
4
+
5
+
## Configuration
6
+
7
+
### Setting up config.json
8
+
9
+
1. Copy one of the example configurations from the `config-examples/` directory:
10
+
```bash
11
+
cp config-examples/us-regions.json config.json
12
+
# OR
13
+
cp config-examples/eu-regions.json config.json
14
+
# OR
15
+
cp config-examples/ap-regions.json config.json
16
+
```
17
+
18
+
2. Modify the `config.json` file as needed for your deployment.
19
+
20
+
### Configuration Format
21
+
22
+
The `config.json` file defines deployment regions and witness settings:
23
+
24
+
```json
25
+
{
26
+
"regions": [
27
+
{
28
+
"region": "us-east-1",
29
+
"witness": false
30
+
},
31
+
{
32
+
"region": "us-east-2",
33
+
"witness": false
34
+
},
35
+
{
36
+
"region": "us-west-2",
37
+
"witness": true
38
+
}
39
+
]
40
+
}
41
+
```
42
+
43
+
**Requirements:**
44
+
- Minimum 3 regions required
45
+
- All regions must be from the same geographical set
46
+
- At least 2 regions must be full replicas (`"witness": false`)
47
+
- Maximum 1 region can be a witness (`"witness": true`)
Set `"witness": true` for a single region that should act as a witness-only replica. Only one witness region is allowed per global table. Witness regions provide additional voting capacity for strong consistency without serving read/write traffic.
60
+
61
+
## Setup
62
+
63
+
1. Install dependencies:
64
+
```bash
65
+
npm install
66
+
```
67
+
68
+
2. Configure your deployment by copying an example:
69
+
```bash
70
+
cp config-examples/us-regions.json config.json
71
+
```
72
+
73
+
3. Modify `config.json` for your specific requirements.
74
+
75
+
## Deploy
76
+
77
+
```bash
78
+
npx cdk deploy --all
79
+
```
80
+
81
+
## Key Implementation
82
+
83
+
The implementation includes:
84
+
85
+
1.**JSON Configuration Loading**: Reads region configuration from `config.json`
86
+
2.**Region Validation**: Ensures regions are valid and from the same geographical set
87
+
3.**Dynamic KMS Stack Creation**: Creates regional KMS stacks based on configuration
88
+
4.**Witness Region Support**: Adds `GlobalTableWitness` property for witness regions
-[DynamoDB Global Tables](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_HowItWorks.html) - Overview of Global Tables functionality
0 commit comments