Answer - D
The main points in this scenario are: even if the CloudFormation stack is deleted,(1) the RDS data needs to be stored, and (2) the S3 bucket with the images should remain (not be deleted).
Option A is incorrect because even if the images are backed up to another bucket, the original bucket would be deleted if the CloudFormation stack is deleted. One of the requirements is to retain the S3 bucket.
Option B is incorrect because the DeletionPolicy attribute for RDS should be snapshot, not retain. After all, with snapshot option, the backup of the RDS instance would be stored in the form of snapshots (which is the requirement). With retain option, CF will keep the RDS instance alive which is unwanted.
Option C is incorrect because the DeletionPolicy of the S3 bucket should be retain, not snapshot.
Option D is CORRECT because it correctly sets the DeletionPolicy of retain on the S3 bucket and snapshot on the RDS instance.
More information on DeletionPolicy on CloudFormation
DeletionPolicy options include:
Retain: You retain the resource in the event of a stack deletion.
Snapshot: You get a snapshot of the resource before it’s deleted. This option is available only for resources that support snapshots.
Delete: You delete the resource along with the stack. This is the default outcome if you don’t set a DeletionPolicy.
AWS Document says:
To keep or copy resources when you delete a stack, you can specify either the Retain or Snapshot policy options.
With the DeletionPolicy attribute, you can preserve or (in some cases) backup a resource when its stack is deleted. You specify a DeletionPolicy attribute for each resource that you want to control. If a resource has no DeletionPolicy attribute, AWS CloudFormation deletes the resource by default.
To keep a resource when its stack is deleted, specify Retain for that resource. You can use retain for any resource. For example, you can retain a nested stack, Amazon S3 bucket, or EC2 instance so that you can continue to use or modify those resources after you delete their stacks.
Note
If you want to modify resources outside of AWS CloudFormation, use a retain policy and then delete the stack. Otherwise, your resources might get out of sync with your AWS CloudFormation template and cause stack errors.
For resources that support snapshots, such as AWS::EC2::Volume, specify Snapshot to have AWS CloudFormation create a snapshot before deleting the resource.
For more information on Cloudformation deletion policy, please visit the below URL-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html