amazon-archives / realworld-serverless-application

This project is inspired by the design and development of the AWS Serverless Application Repository - a production-grade AWS service. Learn how AWS built a production service using serverless technologies.
Apache License 2.0
515 stars 108 forks source link

Add DeletionPolicy to DynamoDB table #51

Open jlhood opened 4 years ago

jlhood commented 4 years ago

We should update the DDB table to have DeletionPolicy: Retain. We'd thought of this before launch, but couldn't get to it in time, because it's not quite as trivial as just adding the line to the template. Our integ tests create/teardown a new stack for every integration test run. Adding that DeletionPolicy would mean a DDB table would be left in the account for each integ test run, eventually hitting the table limit. Unfortunately, CFN doesn't support intrinsic functions in DeletionPolicy so we can't make that a prod stage only feature. So the alternative is to update the integ test setup/teardown code to manually delete the DDB table after the stack delete completes.

benbridts commented 4 years ago

Other options, both are probably worse than a teardown script (but safer, because they rely on CloudFormation for the deletion)

A) Remove the DeletionPolicy from the template before deploying the integration stack (I dislike this option because CloudFormation templates should be treated as (versioned/immutable) artifacts

B) Define the tables twice, once with and once without a DeletionPolicy. Use a condition to only create one of them (this leads to duplicate code and is thus not great either)

C) wait on CloudFormation to support yaml anchors (so the downside of b is gone) or functions in a DeletionPolicy (https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/162)

jlhood commented 4 years ago

@ikben Thanks for the comments and also the reference to the CFN coverage roadmap issue. I'm glad that's being asked for explicitly. That would be the ideal solution IMO.