
Ultimate access to all questions.
An IT team has developed an AWS CloudFormation template to facilitate the deployment and termination of an application. The template provisions an Amazon EC2 instance configured with a user data script for application installation and an Amazon S3 bucket for serving static web content. Upon stack deletion, all associated resources should be removed. However, the team encounters an error during stack deletion, preventing the deletion of the S3 bucket. What is the most efficient solution to ensure that all resources are deleted without errors upon stack deletion?
A
Add a DelelionPolicy attribute to the S3 bucket resource, with the value Delete forcing the bucket to be removed when the stack is deleted.
B
Add a custom resource with an AWS Lambda function with the DependsOn attribute specifying the S3 bucket, and an IAM role. Write the Lambda function to delete all objects from the bucket when RequestType is Delete.
C
Identify the resource that was not deleted. Manually empty the S3 bucket and then delete it.
D
Replace the EC2 and S3 bucket resources with a single AWS OpsWorks Stacks resource. Define a custom recipe for the stack to create and delete the EC2 instance and the S3 bucket.