Destroy an AWS CDK Stack

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

Social Share Links

Send Tweet
Published 6 months ago
Updated 6 months ago

When experimenting with CDK it's possible to deploy a service which is outside of free tier (since nearly all AWS services are supported) and it's useful to be able to delete an entire CDK stack if necessary.

We're going to learn how to delete an entire AWS CDK stack with CDK destroy command.

Instructor: [0:03] At some point, we may decide that we would like to delete our stack entirely. For instance, we would like to migrate it to a different region. Maybe we cannot afford our infrastructure or maybe we just want to delete the app.

[0:12] Given the amount of resources that we currently have in our stack, I mean, the DynamoDB table or the Lambda functions, API gateways, CloudFront distribution, S3 bucket and so on, it would be very tricky to go into CloudFormation and delete all of them one by one. Luckily, there is a better way of solving that problem.

[0:39] I'm going to open up the terminal and run cdk destroy. I'm going to ask whether I want to delete our entire stack. Yes, this is exactly what I want. This is absolutely fine because with CDK, we have a single place where this infrastructure is defined, which is our TypeScript codebase.

[0:55] If we want to, we can deploy the stack again in the future. Of course, the delete operation can take some time, depending on the number and kind of resources that you have in your stack. If you want, you can actually track the process of deleting your entire stack in the events tab of the CloudFormation console.

[1:13] After some time, we can see that our stack has been successfully deleted. If I go back to CloudFormation console and hit refresh button, we can see that our stack is no longer here.

egghead
egghead
~ 4 minutes 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