Soru

Zorluk: KolayAWS CloudFormation

A developer is using an AWS CloudFormation template to deploy an application that includes an Amazon S3 bucket. The S3 bucket contains critical application logs that must be preserved. The developer wants to ensure that the S3 bucket is not deleted when the CloudFormation stack is deleted.

Which action should the developer take to meet this requirement?

  1. A
    Define the S3 bucket in the template and reference its deletion protection settings from AWS Systems Manager Parameter Store.
  2. B
    Manually modify the S3 bucket configuration in the AWS Management Console to enable deletion protection before deleting the stack.
  3. Set the DeletionPolicy attribute to Retain on the S3 bucket resource in the CloudFormation template.Cevap
  4. D
    Configure the stack to fail and rollback to the ROLLBACK_COMPLETE state if the S3 bucket deletion is initiated.

Cevap

Set the DeletionPolicy attribute to Retain on the S3 bucket resource in the CloudFormation template.
The DeletionPolicy attribute in AWS CloudFormation enables you to preserve or back up a resource when its stack is deleted. Setting this policy to Retain on the S3 bucket resource ensures the bucket remains active and intact in the AWS account even after the parent stack is deleted.

Adım Adım Çözüm

1
Identify the target resource (the Amazon S3 bucket) that needs to be preserved.
The target resource is defined in the CloudFormation template.
You must modify the resource's configuration directly in the template definition.
2
Add the DeletionPolicy attribute to the S3 bucket resource block.
The DeletionPolicy attribute is set to Retain.
The Retain policy instructs AWS CloudFormation to keep the resource without deleting it when the stack is deleted.
3
Deploy the updated CloudFormation template.
The stack is updated with the resource retention policy in place.
This ensures that subsequent stack deletion operations will preserve the S3 bucket.

Anahtar Kavram

AWS CloudFormation DeletionPolicy
Tahmini Süre:45s
Bu soruyu puanla