Skip to content

Commit

Permalink
feat(dynamodb): TableV2 supports imports, drift detection, and better…
Browse files Browse the repository at this point in the history
… 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*
  • Loading branch information
colifran authored Sep 6, 2023
1 parent 4ac47df commit e52acd8
Show file tree
Hide file tree
Showing 36 changed files with 41,887 additions and 538 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "34.0.0",
"files": {
"68a3bb36a940031cf3b515e0cad696adef98469abd9e58c2eb45fb68296fcd2e": {
"source": {
"path": "aws-cdk-global-table.template.json",
"packaging": "file"
},
"destinations": {
"current_account-us-east-1": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
"objectKey": "68a3bb36a940031cf3b515e0cad696adef98469abd9e58c2eb45fb68296fcd2e.json",
"region": "us-east-1",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
{
"Resources": {
"Stream790BDEE4": {
"Type": "AWS::Kinesis::Stream",
"Properties": {
"RetentionPeriodHours": 24,
"ShardCount": 1,
"StreamEncryption": {
"Fn::If": [
"AwsCdkKinesisEncryptedStreamsUnsupportedRegions",
{
"Ref": "AWS::NoValue"
},
{
"EncryptionType": "KMS",
"KeyId": "alias/aws/kinesis"
}
]
}
}
},
"Resource": {
"Type": "AWS::DynamoDB::GlobalTable",
"Properties": {
"AttributeDefinitions": [
{
"AttributeName": "pk",
"AttributeType": "S"
},
{
"AttributeName": "sk",
"AttributeType": "N"
}
],
"BillingMode": "PROVISIONED",
"GlobalSecondaryIndexes": [
{
"IndexName": "gsi1",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"WriteProvisionedThroughputSettings": {
"WriteCapacityAutoScalingSettings": {
"MaxCapacity": 20,
"MinCapacity": 1,
"TargetTrackingScalingPolicyConfiguration": {
"TargetValue": 60
}
}
}
},
{
"IndexName": "gsi2",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"WriteProvisionedThroughputSettings": {
"WriteCapacityAutoScalingSettings": {
"MaxCapacity": 30,
"MinCapacity": 1,
"TargetTrackingScalingPolicyConfiguration": {
"TargetValue": 70
}
}
}
}
],
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
},
{
"AttributeName": "sk",
"KeyType": "RANGE"
}
],
"LocalSecondaryIndexes": [
{
"IndexName": "lsi",
"KeySchema": [
{
"AttributeName": "pk",
"KeyType": "HASH"
},
{
"AttributeName": "sk",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
}
}
],
"Replicas": [
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"GlobalSecondaryIndexes": [
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"IndexName": "gsi1",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
}
},
{
"ContributorInsightsSpecification": {
"Enabled": false
},
"IndexName": "gsi2",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
}
}
],
"PointInTimeRecoverySpecification": {
"PointInTimeRecoveryEnabled": true
},
"ReadProvisionedThroughputSettings": {
"ReadCapacityAutoScalingSettings": {
"MaxCapacity": 25,
"MinCapacity": 5,
"TargetTrackingScalingPolicyConfiguration": {
"TargetValue": 70
}
}
},
"Region": "us-east-2",
"TableClass": "STANDARD_INFREQUENT_ACCESS"
},
{
"ContributorInsightsSpecification": {
"Enabled": false
},
"GlobalSecondaryIndexes": [
{
"IndexName": "gsi1",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 15
}
},
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"IndexName": "gsi2",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
}
}
],
"PointInTimeRecoverySpecification": {
"PointInTimeRecoveryEnabled": true
},
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
},
"Region": "us-west-2",
"TableClass": "STANDARD"
},
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"GlobalSecondaryIndexes": [
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"IndexName": "gsi1",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
}
},
{
"ContributorInsightsSpecification": {
"Enabled": true
},
"IndexName": "gsi2",
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
}
}
],
"KinesisStreamSpecification": {
"StreamArn": {
"Fn::GetAtt": [
"Stream790BDEE4",
"Arn"
]
}
},
"PointInTimeRecoverySpecification": {
"PointInTimeRecoveryEnabled": true
},
"ReadProvisionedThroughputSettings": {
"ReadCapacityUnits": 10
},
"Region": "us-east-1",
"TableClass": "STANDARD_INFREQUENT_ACCESS"
}
],
"SSESpecification": {
"SSEEnabled": true,
"SSEType": "KMS"
},
"StreamSpecification": {
"StreamViewType": "NEW_AND_OLD_IMAGES"
},
"TableName": "my-global-table",
"TimeToLiveSpecification": {
"AttributeName": "attr",
"Enabled": true
},
"WriteProvisionedThroughputSettings": {
"WriteCapacityAutoScalingSettings": {
"MaxCapacity": 20,
"MinCapacity": 1,
"TargetTrackingScalingPolicyConfiguration": {
"TargetValue": 60
}
}
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
}
},
"Conditions": {
"AwsCdkKinesisEncryptedStreamsUnsupportedRegions": {
"Fn::Or": [
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"cn-north-1"
]
},
{
"Fn::Equals": [
{
"Ref": "AWS::Region"
},
"cn-northwest-1"
]
}
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "34.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "awscdkglobaltableintegDefaultTestDeployAssertA2A9E81F.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"34.0.0"}
Loading

0 comments on commit e52acd8

Please sign in to comment.