1. 5
    Clear an initial AWS CDK stack to start building an app from scratch
    1m 22s
⚠️ This lesson is retired and might contain outdated information.

Clear an initial AWS CDK stack to start building an app from scratch

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

Social Share Links

Send Tweet
Published 4 years ago
Updated 5 months ago

In this quick lesson we're going to clear out the SQS Queue and SNS Topic that was created for us when we created a CDK app with cdk init in order for us to be able to start building our app from scratch.

Instructor: [0:00] Now is the time to clean. Our stack currently contains an SQS::Queue and also an SNS::Topic. Both of those are not things that we are going to need to build our app, so let me go over here and delete all of that. We are both going to delete the Queue and also the Topic as well as to remove all those unused imports.

[0:16] If I save that, right now our todo app stack is completely empty. Let's see what's going to happen if I deploy that. Let me run cdk diff in order to compare the changes between the currently deployed stack and the stack that we are about to deploy.

[0:28] Here in the Resources section, we can see that we are about to delete all those resources because this is exactly what we want. We want to start from scratch. Right now, if I run cdk deploy it's going to deploy this empty stack effectively deleting everything that was deployed before.

[0:42] That's the thing with CDK. You always get deployed exactly the things that you asked for and the things that are no longer needed will get deleted. You always have a consistent state of your infrastructure because this stack accurately reflects what exactly is going to be deployed to AWS Cloud once you run cdk deploy.

[0:59] Our empty stack has been deployed. Let's take a look inside of AWS Console to see exactly what was deployed. If I refresh that section over here, we can see that currently we barely have any resources. The only thing that remains is the internal CDKMetadata.

[1:12] We can also take a look inside of Events section over here to see that we were deleting all those resources from AWS. Right now, we are more than ready to start building our app from scratch.

ed leach
ed leach
~ 4 years ago

I think you need to do "npm run-script build" before doing the diff.

Quang Le
Quang Le
~ 3 years ago

If someone happens to get the error Error: This stack uses assets, so the toolkit stack must be deployed to the environment (Run "cdk bootstrap aws://unknown-account/unknown-region"), then check what aws profile is currently used (find in in ~/.aws/credentials), then do the bootstrap with the command cdk bootstrap --profile profile-name before running aws deploy

Markdown supported.
Become a member to join the discussionEnroll Today