Skip to content
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

dynamodb.Table needs a removalPolicy prop #2710

Closed
mansisorathiya opened this issue May 31, 2019 · 2 comments · Fixed by MechanicalRock/tech-radar#14 · 4 remaining pull requests
Closed

dynamodb.Table needs a removalPolicy prop #2710

mansisorathiya opened this issue May 31, 2019 · 2 comments · Fixed by MechanicalRock/tech-radar#14 · 4 remaining pull requests
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@mansisorathiya
Copy link

How to attach Deletion policy to software.amazon.awscdk.services.dynamodb.Table Class ?

@NGL321 NGL321 added @aws-cdk/aws-dynamodb Related to Amazon DynamoDB guidance Question that needs advice or information. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jun 3, 2019
@NGL321 NGL321 self-assigned this Jun 3, 2019
@NGL321
Copy link
Contributor

NGL321 commented Jun 4, 2019

Thanks for reaching out!
DeletionPolicy is an enumerable option of a CDK resource (cfnresource) in the Construct Library! I recommend taking a look at the Construct Library documentation.

Try something along the lines of: resource.options.deletionPolicy = DeletionPolicy.Retain;.

Let me know if this is what you were trying to accomplish!

@NGL321 NGL321 added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. closing-soon This issue will automatically close in 4 days unless further comments are made. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jun 4, 2019
@eladb
Copy link
Contributor

eladb commented Jun 4, 2019

I believe @mansisorathiya is asking about the dynamodb.Table construct (L2) and not the dynamodb.CfnTable construct (L1). Indeed, L1 have an options field which is where you can specify raw CloudFormation options for the low-level resource.

Some L2s (such as s3.Bucket) actually expose a removalPolicy prop which offers an API for defining the deletion policy, but we haven't gotten around to adding those to all stateful L2s (see #2282). It should be easy to add if you anyone is interested to pick this up.

As a workaround, you should be able to use an escape hatch like so:

const resource = table.node.findChild('Resource') as CfnResource;
resource.options.deletionPolicy = DeletionPolicy.Retain;

@eladb eladb changed the title How to specify DeletionPolicy to dynamodb ? dynamodb.Table needs a removalPolicy prop Jun 4, 2019
@NGL321 NGL321 closed this as completed Jun 17, 2019
RomainMuller added a commit that referenced this issue Jun 26, 2019
Add support for RemovalPolicy on DynamoDB `Table`s, defaulting to
`RemovalPolicy.RETAIN` as the resource is inherently stateful.

Fixes #2710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment