-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dynamodb): add option to skip waiting for global replication to finish #16983
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @TheSPD! Looks fine overall, I have a couple of minor comments though.
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
replicationRegions
property, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I love the name. How about waitForReplicationToFinish?: boolean
, default true
?
@@ -49,12 +49,13 @@ export async function isCompleteHandler(event: IsCompleteRequest): Promise<IsCom | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
@@ -1524,6 +1535,7 @@ export class Table extends TableBase { | |||
properties: { | |||
TableName: this.tableName, | |||
Region: region, | |||
AsynchronousReplicationEnabled: asynchronousReplicationEnabled || false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do any defaulting here. This way, the existing templates will be unchanged.
AsynchronousReplicationEnabled: asynchronousReplicationEnabled || false, | |
SkipReplicationCompletedWait: waitForReplicationToFinish === undefined ? undefined : !waitForReplicationToFinish, | |
@@ -2420,6 +2421,7 @@ describe('global', () => { | |||
Ref: 'TableCD117FA1', | |||
}, | |||
Region: 'eu-central-1', | |||
AsynchronousReplicationEnabled: false, | |||
}, | |||
Condition: 'TableStackRegionNotEqualseucentral199D46FC0', | |||
}, ResourcePart.CompleteDefinition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new test here, passing waitForReplicationToFinish
as false
.
@@ -209,7 +209,8 @@ | |||
"TableName": { | |||
"Ref": "TableCD117FA1" | |||
}, | |||
"Region": "eu-west-2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for the contribution @TheSPD!
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