aws-samples/amazon-dynamodb-labs

Prevent stack deletion unless DynamoDB resources are cleaned up

switch180 opened this issue · 1 comments

Issue: Tables are left scaled up after stack deletion. We have banners in the lab explaining the importance of deleting DDB tables, but these aren't foolproof.

Recommended resolution:

  • 1. Tables in the hands on python labs are tagged on creation
  • 2. We should create a CFN custom resource or similar that blocks stack deletion if the DDB tables are not cleaned up
  • 3. We should send an error message in the stack events if the tables still exist, and return a hyperlink to AWS resource manager to review the list of tables and clean them up

My customer left the lab running and it charged around 10K

I have a few suggestions to help avoid it.

  1. Add the billing alarm to the DDB CFN, also, add a step to enable the billing metric before running the CFN - some docs below
    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudwatch.html#cloudwatch-sample-billing-alarm
    https://github.com/pyraven/cloudformation_sms_alarm

  2. or, create the CFN with lower RCU/WCU, and allow the user to decide the number, so there is no excuse that they don't know it is going to cost a fortune.