Which solution will meet these requirements?
Create a Lambda function to delete objects from an S3 bucket. Add the Lambda function as a custom resource in the CloudFormation stack with a DependsOn attribute that points to the S3 bucket resource.
Modify the CloudFormation stack to attach a DeletionPolicy attribute with a value of Delete to the S3 bucket.
Update the CloudFormation stack to add a DeletionPolicy attribute with a value of Snapshot for the S3 bucket resource
Update the CloudFormation template to create an Amazon Elastic File System (Amazon EFS) file system to store temporary files instead of Amazon S3. Configure the Lambda functions to run in the same VPC as the EFS file system.
Explanations:
A Lambda function can be used as a custom resource in CloudFormation to delete objects from the S3 bucket before the stack deletion process. TheDependsOnattribute ensures that the Lambda function runs before the S3 bucket is deleted, thus resolving the deletion failure.
TheDeletionPolicyattribute with a value ofDeleteapplies to AWS resources like EC2 instances or RDS databases, but not to S3 buckets. S3 objects are deleted based on object lifecycle policies or manual intervention, not through theDeletionPolicy.
TheDeletionPolicyattribute with a value ofSnapshotis used to create backups of resources such as EC2 instances or RDS databases before deletion. It does not apply to S3 buckets, which are not designed to have snapshots.
Using Amazon EFS instead of S3 is a major architecture change and is not required. The issue with stack deletion is related to S3 bucket handling, not the need for a completely different storage solution.