Skip to content

Commit e52acd8

Browse files
authored
feat(dynamodb): TableV2 supports imports, drift detection, and better control over replicas (#27023)
This PR is for the implementation of the `TableV2` construct which provides support for the `GlobalTable` resource. Please reference the following RFC: [aws/aws-cdk-rfcs@master/text/0510-dynamodb-global-table.md](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0510-dynamodb-global-table.md?rgh-link-date=2023-07-28T17%3A49%3A45Z) Closes #16118 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4ac47df commit e52acd8

36 files changed

+41887
-538
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "34.0.0",
3+
"files": {
4+
"68a3bb36a940031cf3b515e0cad696adef98469abd9e58c2eb45fb68296fcd2e": {
5+
"source": {
6+
"path": "aws-cdk-global-table.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-us-east-1": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
12+
"objectKey": "68a3bb36a940031cf3b515e0cad696adef98469abd9e58c2eb45fb68296fcd2e.json",
13+
"region": "us-east-1",
14+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
15+
}
16+
}
17+
}
18+
},
19+
"dockerImages": {}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
{
2+
"Resources": {
3+
"Stream790BDEE4": {
4+
"Type": "AWS::Kinesis::Stream",
5+
"Properties": {
6+
"RetentionPeriodHours": 24,
7+
"ShardCount": 1,
8+
"StreamEncryption": {
9+
"Fn::If": [
10+
"AwsCdkKinesisEncryptedStreamsUnsupportedRegions",
11+
{
12+
"Ref": "AWS::NoValue"
13+
},
14+
{
15+
"EncryptionType": "KMS",
16+
"KeyId": "alias/aws/kinesis"
17+
}
18+
]
19+
}
20+
}
21+
},
22+
"Resource": {
23+
"Type": "AWS::DynamoDB::GlobalTable",
24+
"Properties": {
25+
"AttributeDefinitions": [
26+
{
27+
"AttributeName": "pk",
28+
"AttributeType": "S"
29+
},
30+
{
31+
"AttributeName": "sk",
32+
"AttributeType": "N"
33+
}
34+
],
35+
"BillingMode": "PROVISIONED",
36+
"GlobalSecondaryIndexes": [
37+
{
38+
"IndexName": "gsi1",
39+
"KeySchema": [
40+
{
41+
"AttributeName": "pk",
42+
"KeyType": "HASH"
43+
}
44+
],
45+
"Projection": {
46+
"ProjectionType": "ALL"
47+
},
48+
"WriteProvisionedThroughputSettings": {
49+
"WriteCapacityAutoScalingSettings": {
50+
"MaxCapacity": 20,
51+
"MinCapacity": 1,
52+
"TargetTrackingScalingPolicyConfiguration": {
53+
"TargetValue": 60
54+
}
55+
}
56+
}
57+
},
58+
{
59+
"IndexName": "gsi2",
60+
"KeySchema": [
61+
{
62+
"AttributeName": "pk",
63+
"KeyType": "HASH"
64+
}
65+
],
66+
"Projection": {
67+
"ProjectionType": "ALL"
68+
},
69+
"WriteProvisionedThroughputSettings": {
70+
"WriteCapacityAutoScalingSettings": {
71+
"MaxCapacity": 30,
72+
"MinCapacity": 1,
73+
"TargetTrackingScalingPolicyConfiguration": {
74+
"TargetValue": 70
75+
}
76+
}
77+
}
78+
}
79+
],
80+
"KeySchema": [
81+
{
82+
"AttributeName": "pk",
83+
"KeyType": "HASH"
84+
},
85+
{
86+
"AttributeName": "sk",
87+
"KeyType": "RANGE"
88+
}
89+
],
90+
"LocalSecondaryIndexes": [
91+
{
92+
"IndexName": "lsi",
93+
"KeySchema": [
94+
{
95+
"AttributeName": "pk",
96+
"KeyType": "HASH"
97+
},
98+
{
99+
"AttributeName": "sk",
100+
"KeyType": "RANGE"
101+
}
102+
],
103+
"Projection": {
104+
"ProjectionType": "ALL"
105+
}
106+
}
107+
],
108+
"Replicas": [
109+
{
110+
"ContributorInsightsSpecification": {
111+
"Enabled": true
112+
},
113+
"GlobalSecondaryIndexes": [
114+
{
115+
"ContributorInsightsSpecification": {
116+
"Enabled": true
117+
},
118+
"IndexName": "gsi1",
119+
"ReadProvisionedThroughputSettings": {
120+
"ReadCapacityUnits": 10
121+
}
122+
},
123+
{
124+
"ContributorInsightsSpecification": {
125+
"Enabled": false
126+
},
127+
"IndexName": "gsi2",
128+
"ReadProvisionedThroughputSettings": {
129+
"ReadCapacityUnits": 10
130+
}
131+
}
132+
],
133+
"PointInTimeRecoverySpecification": {
134+
"PointInTimeRecoveryEnabled": true
135+
},
136+
"ReadProvisionedThroughputSettings": {
137+
"ReadCapacityAutoScalingSettings": {
138+
"MaxCapacity": 25,
139+
"MinCapacity": 5,
140+
"TargetTrackingScalingPolicyConfiguration": {
141+
"TargetValue": 70
142+
}
143+
}
144+
},
145+
"Region": "us-east-2",
146+
"TableClass": "STANDARD_INFREQUENT_ACCESS"
147+
},
148+
{
149+
"ContributorInsightsSpecification": {
150+
"Enabled": false
151+
},
152+
"GlobalSecondaryIndexes": [
153+
{
154+
"IndexName": "gsi1",
155+
"ReadProvisionedThroughputSettings": {
156+
"ReadCapacityUnits": 15
157+
}
158+
},
159+
{
160+
"ContributorInsightsSpecification": {
161+
"Enabled": true
162+
},
163+
"IndexName": "gsi2",
164+
"ReadProvisionedThroughputSettings": {
165+
"ReadCapacityUnits": 10
166+
}
167+
}
168+
],
169+
"PointInTimeRecoverySpecification": {
170+
"PointInTimeRecoveryEnabled": true
171+
},
172+
"ReadProvisionedThroughputSettings": {
173+
"ReadCapacityUnits": 10
174+
},
175+
"Region": "us-west-2",
176+
"TableClass": "STANDARD"
177+
},
178+
{
179+
"ContributorInsightsSpecification": {
180+
"Enabled": true
181+
},
182+
"GlobalSecondaryIndexes": [
183+
{
184+
"ContributorInsightsSpecification": {
185+
"Enabled": true
186+
},
187+
"IndexName": "gsi1",
188+
"ReadProvisionedThroughputSettings": {
189+
"ReadCapacityUnits": 10
190+
}
191+
},
192+
{
193+
"ContributorInsightsSpecification": {
194+
"Enabled": true
195+
},
196+
"IndexName": "gsi2",
197+
"ReadProvisionedThroughputSettings": {
198+
"ReadCapacityUnits": 10
199+
}
200+
}
201+
],
202+
"KinesisStreamSpecification": {
203+
"StreamArn": {
204+
"Fn::GetAtt": [
205+
"Stream790BDEE4",
206+
"Arn"
207+
]
208+
}
209+
},
210+
"PointInTimeRecoverySpecification": {
211+
"PointInTimeRecoveryEnabled": true
212+
},
213+
"ReadProvisionedThroughputSettings": {
214+
"ReadCapacityUnits": 10
215+
},
216+
"Region": "us-east-1",
217+
"TableClass": "STANDARD_INFREQUENT_ACCESS"
218+
}
219+
],
220+
"SSESpecification": {
221+
"SSEEnabled": true,
222+
"SSEType": "KMS"
223+
},
224+
"StreamSpecification": {
225+
"StreamViewType": "NEW_AND_OLD_IMAGES"
226+
},
227+
"TableName": "my-global-table",
228+
"TimeToLiveSpecification": {
229+
"AttributeName": "attr",
230+
"Enabled": true
231+
},
232+
"WriteProvisionedThroughputSettings": {
233+
"WriteCapacityAutoScalingSettings": {
234+
"MaxCapacity": 20,
235+
"MinCapacity": 1,
236+
"TargetTrackingScalingPolicyConfiguration": {
237+
"TargetValue": 60
238+
}
239+
}
240+
}
241+
},
242+
"UpdateReplacePolicy": "Delete",
243+
"DeletionPolicy": "Delete"
244+
}
245+
},
246+
"Conditions": {
247+
"AwsCdkKinesisEncryptedStreamsUnsupportedRegions": {
248+
"Fn::Or": [
249+
{
250+
"Fn::Equals": [
251+
{
252+
"Ref": "AWS::Region"
253+
},
254+
"cn-north-1"
255+
]
256+
},
257+
{
258+
"Fn::Equals": [
259+
{
260+
"Ref": "AWS::Region"
261+
},
262+
"cn-northwest-1"
263+
]
264+
}
265+
]
266+
}
267+
},
268+
"Parameters": {
269+
"BootstrapVersion": {
270+
"Type": "AWS::SSM::Parameter::Value<String>",
271+
"Default": "/cdk-bootstrap/hnb659fds/version",
272+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
273+
}
274+
},
275+
"Rules": {
276+
"CheckBootstrapVersion": {
277+
"Assertions": [
278+
{
279+
"Assert": {
280+
"Fn::Not": [
281+
{
282+
"Fn::Contains": [
283+
[
284+
"1",
285+
"2",
286+
"3",
287+
"4",
288+
"5"
289+
],
290+
{
291+
"Ref": "BootstrapVersion"
292+
}
293+
]
294+
}
295+
]
296+
},
297+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
298+
}
299+
]
300+
}
301+
}
302+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "34.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "awscdkglobaltableintegDefaultTestDeployAssertA2A9E81F.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"34.0.0"}

0 commit comments

Comments
 (0)