Stack Deletion
Stack deletions often fail because a resource managed by the corresponding CloudFormation stack could not be deleted.
First, we need to check what error was returned from CloudFormation.
Below are solutions for some common resource-deletion errors:
Bucket is not empty
Error: "The bucket you tried to delete is not empty (Service: Amazon S3; Status Code: 409; Error Code: BucketNotEmpty)"
Reason: The S3 Bucket must not contain any objects (files or directories) in order to be deleted.
Solution: Open deployed stack in AWS console, go to S3 buckets that could not be deleted, and delete all files and directories in it.
Api Gateway custom domain names
Error: "Deleting stage Prod failed. Please remove all base path mappings related to the stage in your domains: prefix.yourdomain.com"
Reason: This happens if a user attached a custom domain name to the API Gateway.
Solution:
- Open the stack in the AWS console.
- Switch to the Resources tab, and locate ApiGateway which failed to be deleted.
- Copy the domain name of the API that had the error.
- Open the API Gateway page in the AWS console.
- Switch to the "Custom Domain Names" tab and locate the problematic domain name.
You have 2 options depending on your project architecture:
- Remove the link to the API gateway.
- In the domain name details window, switch to "Configure API mapping"
- Delete the link
- Delete the domain name