Delete and Restore an AWS CDK Stack

Tomasz Łakomy
InstructorTomasz Łakomy
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

There is a slight chance that your book startup didn't work out. Or maybe you created your CDK project just as a learning exercise. Either way, it's best to clean up after yourself in order to not get hit with any surprise charges.

You can easily destroy your stack and its resources from the command line with cdk destroy. But don't worry. You can easily restore your stack with cdk deploy. This is the power of infrastructure as code!

Tomasz Łakomy: [0:00] It's possible that our book API startup is not going to be a huge success. As such, we should learn how to delete a CDK stack.

[0:07] In order to delete a CDK stack, run cdk destroy. This is going to ask us if we want to delete the stack. Yes, we want to delete it. This is fine, by the way, because if you want to restore the stack, we simply have to deploy it again. This is going to take a second because it has to delete all the resources in our CloudFormation stack.

[0:25] Now it's gone, but let's double check. I'm going to go to AWS Console and navigate to CloudFormation. It seems that our stack was deleted because it's not here on the list. Suppose we got extra funding and we want to restore our stack. We can run cdk deploy again and this took a second because it had to recreate all the Lambda functions, DynamoDB table and so on.

[0:47] This is the power of CDK or infrastructure as code in general. We are always able to deploy our stack in a different AWS account, in a different region, with no manual steps required because everything is defined in code.

egghead
egghead
~ 13 seconds ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today