What is the MOST likely cause and how can the DevOps engineer mitigate this problem for this and future versions of the website?
Deletion has failed because the S3 bucket has an active website configuration. Modify the CloudFormation template to remove the WebsiteConfiguration property from the S3 bucket resource
Deletion has failed because the S3 bucket is not empty. Modify the custom resource’s AWS Lambda function code to recursively empty the bucket when RequestType is Delete.
Deletion has failed because the custom resource does not define a deletion policy. Add a DeletionPolicy property to the custom resource definition with a value of RemoveOnDeletion.
Deletion has failed because the S3 bucket is not empty. Modify the S3 bucket resource in the CloudFormation template to add a DeletionPolicy property with a value of Empty.
Explanations:
Deletion fails because of content in the S3 bucket, not due to the website configuration. Removing the WebsiteConfiguration would not resolve the issue.
The issue is most likely due to the S3 bucket not being empty. The custom resource should be modified to empty the bucket during the delete request.
A DeletionPolicy of RemoveOnDeletion does not solve the issue. It applies to AWS resources but does not empty the S3 bucket on deletion.
The DeletionPolicy of Empty is not a valid option for S3 buckets. The correct approach is to handle the deletion logic within a custom resource.