AWS Certified Solutions Architect – Professional (SAP-C02) — Question 493

Accompany runs an application on Amazon EC2 and AWS Lambda. The application stores temporary data in Amazon S3. The S3 objects are deleted after 24 hours.

The company deploys new versions of the application by launching AWS CloudFormation stacks. The stacks create the required resources. After validating a new version, the company deletes the old stack. The deletion of an old development stack recently failed. A solutions architect needs to resolve this issue without major architecture changes.

Which solution will meet these requirements?

Answer options

Correct answer: A

Explanation

CloudFormation cannot delete an Amazon S3 bucket if it contains any objects, which causes the stack deletion process to fail. Implementing a Lambda function as a custom resource to empty the bucket before CloudFormation attempts to delete it ensures the bucket is empty and can be successfully removed. Modifying the DeletionPolicy does not solve the issue of deleting a non-empty bucket, and switching to Amazon EFS requires significant architectural modifications.