-
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
fix(aws-dynamodb): Propogate DeletionPolicy to replicas #16968
Conversation
fde98f4
to
2a56d7b
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 PR @TheSPD! Two small comments from me.
expect(SynthUtils.toCloudFormation(stack).Conditions).toEqual({ | ||
TableStackRegionNotEqualseuwest2A03859E7: { | ||
'Fn::Not': [ | ||
{ 'Fn::Equals': ['eu-west-2', { Ref: 'AWS::Region' }] }, | ||
], | ||
}, | ||
TableStackRegionNotEqualseucentral199D46FC0: { | ||
'Fn::Not': [ | ||
{ 'Fn::Equals': ['eu-central-1', { Ref: 'AWS::Region' }] }, | ||
], | ||
}, | ||
}); | ||
}); |
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.
Any reason for this assertion here? I don't really see it having much to do with this test... I would just remove it:
expect(SynthUtils.toCloudFormation(stack).Conditions).toEqual({ | |
TableStackRegionNotEqualseuwest2A03859E7: { | |
'Fn::Not': [ | |
{ 'Fn::Equals': ['eu-west-2', { Ref: 'AWS::Region' }] }, | |
], | |
}, | |
TableStackRegionNotEqualseucentral199D46FC0: { | |
'Fn::Not': [ | |
{ 'Fn::Equals': ['eu-central-1', { Ref: 'AWS::Region' }] }, | |
], | |
}, | |
}); | |
}); |
@@ -1537,6 +1537,7 @@ export class Table extends TableBase { | |||
const currentRegion = new CustomResource(this, `Replica${region}`, { | |||
serviceToken: provider.provider.serviceToken, | |||
resourceType: 'Custom::DynamoDBReplica', | |||
removalPolicy: removalPolicy, |
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.
What about the default removalPolicy
?
The default RemovalPolicy
for Table
is RETAIN
. It seems like we should also make it RETAIN
for the Custom Resource in that case as well?
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.
passing in the default in the method parameters
2a56d7b
to
83dc9bb
Compare
Pull request has been modified.
83dc9bb
to
bdb3731
Compare
@@ -2412,6 +2412,7 @@ describe('global', () => { | |||
Region: 'eu-west-2', | |||
}, | |||
Condition: 'TableStackRegionNotEqualseuwest2A03859E7', | |||
DeletionPolicy: CfnDeletionPolicy.RETAIN, |
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.
Testing for default behavior
@@ -1537,6 +1537,7 @@ export class Table extends TableBase { | |||
const currentRegion = new CustomResource(this, `Replica${region}`, { | |||
serviceToken: provider.provider.serviceToken, | |||
resourceType: 'Custom::DynamoDBReplica', | |||
removalPolicy: removalPolicy, |
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.
passing in the default in the method parameters
Looks like some linter errors snuck through 🙂:
|
@TheSPD I actually had another thought: does making the |
bdb3731
to
2e8ce06
Compare
Hmm, I understand your concerns here @skinny85, I think it'll leave all those lambdas and step functions hanging around. However, my 2 cents in trying to change your opinions on this.
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Actually @TheSPD, I just realized you're propagating the Could you do a test, and let me know if it works like that? |
I'm closing this one due to inactivity. @TheSPD let me know if you want to resume working on this. |
Motivation: When a Global DDB Table is created with multiple regions, the retention policy is not propagated to the
Custom::DynamoDBReplica
resources that get created under cloudformation.Say if we want the retentionpolicy to be "Retain", when we delete the CDK object, the table in main region is retained whereas all the replicas are deleted. This is not ideal.
Fixes #17011
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license