Exam SAP-C02 All QuestionsBrowse all questions from this exam
Question 497

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?

    Correct Answer: A

    To resolve the issue of CloudFormation stack deletion failing due to non-empty S3 buckets, the best solution is to create a Lambda function that deletes objects from the S3 bucket. This Lambda function should be added as a custom resource in the CloudFormation stack with a DependsOn attribute pointing to the S3 bucket resource. This ensures that the Lambda function is invoked to empty the bucket before CloudFormation attempts to delete it, thereby preventing any deletion failures.

Discussion
toma

it should be A

AlagongOption: A

IT SHOULD BE A

gfhbox0083Option: A

A, for sure. DeletionPolicy: Delete: The DeletionPolicy attribute in CloudFormation is used to specify what should happen to a resource when the stack is deleted. The value Delete indicates that CloudFormation should delete the resource (in this case, the S3 bucket) when the stack is deleted. Non-Empty Buckets: The problem with this approach is that CloudFormation cannot delete an S3 bucket if it contains any objects. The DeletionPolicy: Delete does not change this behavior; it only specifies that the bucket should be deleted, which will still fail if the bucket is not empty.

gfhbox0083

A, for sure. DeletionPolicy: Delete: The DeletionPolicy attribute in CloudFormation is used to specify what should happen to a resource when the stack is deleted. The value Delete indicates that CloudFormation should delete the resource (in this case, the S3 bucket) when the stack is deleted. Non-Empty Buckets: The problem with this approach is that CloudFormation cannot delete an S3 bucket if it contains any objects. The DeletionPolicy: Delete does not change this behavior; it only specifies that the bucket should be deleted, which will still fail if the bucket is not empty.

ahrentomOption: A

you can´t delete a S3 bucket with objects in it. So A is correct

Russs99Option: B

By setting the Deletion Policy attribute to Delete in the stack, you ensure that the S3 bucket and its contents are deleted when the CloudFormation stack is deleted. This best option for the scenario and and aligns with the desired behavior of removing old resources when the stack is deleted.

AhmedSalemOption: A

I will go for A. Using Lambda function as a custom resource ensures that the S3 bucket is emptied before the stack is deleted. DependsOn Attribute ensures the Lambda function runs and completes before attempting to delete the S3 bucket, thus preventing deletion failure.

grandcanyonOption: B

When you specify a DeletionPolicy attribute with a value of Delete for an S3 bucket in a CloudFormation template, CloudFormation will delete the bucket and all its contents during stack deletion. This approach addresses the issue of the stack deletion failing due to the bucket not being empty.

HelpnosenseOption: C

Votes C. After s3 snapshot, cloud formation will proceed s3 bucket deletion. A is right but compare to c it doesn't match the requirement in the question. "resolve this issue without major architecture changes." Also the data become useless only after 24 hours. A delete everything regardless. C is better.

mifuneOption: A

"DependsOn" attribute ensures that the Lambda function will always be invoked before the S3 bucket is deleted in a CloudFormation. Answer A.