feat(dynamodb): add option to skip waiting for global replication to finish#16983
Conversation
|
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
98c73b8 to
ca08007
Compare
| * Whether Asynchronous Replication is enabled. If enabled, the | ||
| * CloudFormation resource will not wait for replication operation to be | ||
| * completed. | ||
| * DO NOT USE this for adding multiple replication regions in one deployment, | ||
| * as CloudFormation only supports one region replication at a time. |
There was a problem hiding this comment.
These docs need some work I think.
- The first sentence doesn't really say anything.
- It doesn't mention that it's related to the
replicationRegionsproperty, and is ignored if that property is not set. - Not sure I understand what you mean by the warning...? Each region gets its own Custom Resource, so what's the problem in enabling it with multiple regions?
There was a problem hiding this comment.
Ok, let's reword that section a little bit then, and link to that document.
| * | ||
| * @default false | ||
| */ | ||
| readonly asynchronousReplicationEnabled?: boolean; |
There was a problem hiding this comment.
I'm not sure I love the name. How about waitForReplicationToFinish?: boolean, default true?
| const replicas = data.Table?.Replicas ?? []; | ||
| const regionReplica = replicas.find(r => r.RegionName === event.ResourceProperties.Region); | ||
| const replicaActive = !!(regionReplica?.ReplicaStatus === 'ACTIVE'); | ||
| const asynchronousReplicationEnabled = event.ResourceProperties.AsynchronousReplicationEnabled; |
There was a problem hiding this comment.
Let's turn this into a negative, so that it's not enabled by default. So, let's call the property something like SkipReplicationCompletedWait, and it will be false if undefined. Even better, let's make the false case explicit:
| const asynchronousReplicationEnabled = event.ResourceProperties.AsynchronousReplicationEnabled; | |
| const skipReplicationCompletedWait = event.ResourceProperties.SkipReplicationCompletedWait ?? false; |
| properties: { | ||
| TableName: this.tableName, | ||
| Region: region, | ||
| AsynchronousReplicationEnabled: asynchronousReplicationEnabled || false, |
There was a problem hiding this comment.
Let's not do any defaulting here. This way, the existing templates will be unchanged.
| AsynchronousReplicationEnabled: asynchronousReplicationEnabled || false, | |
| SkipReplicationCompletedWait: waitForReplicationToFinish === undefined ? undefined : !waitForReplicationToFinish, | |
| AsynchronousReplicationEnabled: false, | ||
| }, | ||
| Condition: 'TableStackRegionNotEqualseucentral199D46FC0', | ||
| }, ResourcePart.CompleteDefinition); |
There was a problem hiding this comment.
We need a new test here, passing waitForReplicationToFinish as false.
| "TableName": { | ||
| "Ref": "TableCD117FA1" | ||
| }, | ||
| "Region": "eu-west-2" |
There was a problem hiding this comment.
If you follow my advice from above, all of these changes can be reverted.
ca08007 to
436fd2a
Compare
Pull request has been modified.
d976eb4 to
4f6e696
Compare
4f6e696 to
6633c39
Compare
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Our CFN Custom Resource for global DynamoDB Tables did not correctly handle changing the `waitForReplicationToFinish` parameter introduced in aws#16983 - adding it to an existing replica would error out by attempting to re-create the existing replica. Fix this by adding a check in the Custom Resource whether a replica already exists.
…#17842) Our CFN Custom Resource for global DynamoDB Tables did not correctly handle changing the `waitForReplicationToFinish` parameter introduced in #16983 - adding it to an existing replica would error out by attempting to re-create the existing replica. Fix this by adding a check in the Custom Resource whether a replica already exists. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…finish (aws#16983) Motivation - On large tables, replication takes long time to complete. CloudFormation has a hard timeout of 1 hour on the Custom Resources, to bypass this, we want to have the replication continue in background based on a property. Fixes aws#16611 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…aws#17842) Our CFN Custom Resource for global DynamoDB Tables did not correctly handle changing the `waitForReplicationToFinish` parameter introduced in aws#16983 - adding it to an existing replica would error out by attempting to re-create the existing replica. Fix this by adding a check in the Custom Resource whether a replica already exists. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Motivation - On large tables, replication takes long time to complete. CloudFormation has a hard timeout of 1 hour on the Custom Resources, to bypass this, we want to have the replication continue in background based on a property.
Fixes #16611
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license