QuestionQ48

Configuration Management and IaC

A company has created a static website hosted in an Amazon S3 bucket. The website is deployed through AWS CloudFormation. The CloudFormation template defines an S3 bucket and a custom resource that copies content from a source location into the bucket.

The company has decided it must move the website to a new location, so the existing CloudFormation stack needs to be deleted and recreated. However, CloudFormation reports that the stack could not be deleted successfully.

What is the MOST likely cause, and how can the DevOps engineer mitigate this issue for this and future website versions?

Explanation

An S3 bucket can be deleted only when it is empty. Because the custom resource copies website content into the bucket, its Lambda handler must process the CloudFormation Delete request by recursively deleting that content before reporting success, allowing CloudFormation to delete the bucket. CloudFormation sends custom-resource providers a request whose RequestType is Delete when the stack is deleted.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!