Delete S3 Buckets

There are 2 buckets that got created as part of this workshop, one was created by SAM CLI and the other one was created in Chapter 4 by CodePipeline. To delete these buckets, we should empty them first and then proceed to delete them.

First Bucket

The first bucket to cleanup is the one created by SAM CLI, you can find out the bucket name with the following command:

aws cloudformation describe-stack-resources \
--stack-name aws-sam-cli-managed-default \
| jq -r '.StackResources[] | select(.ResourceType=="AWS::S3::Bucket") | .PhysicalResourceId'

Empty the bucket by going to the S3 console. And then Delete it.

EmptyBucket

Second Bucket

The second bucket was created by CDK to be used by CodePipeline. Let’s find the bucket name with the following command:

aws cloudformation describe-stack-resources \
--stack-name sam-app-cicd \
| jq -r '.StackResources[] | select(.ResourceType=="AWS::S3::Bucket") | .PhysicalResourceId'

Then empty the bucket as well:

EmptyBucket