Skip to Content

SOA-C02: Which solution keep EC2 instances and data on AWS CloudFormation

Question

A company uses AWS CloudFormation to manage a stack of Amazon EC2 instances on AWS. A SysOps administrator needs to keep the instances and all of the instances’ data, even if someone deletes the stack. Which solution will meet these requirements?

A. Set the DeletionPolicy attribute to Snapshot for the EC2 instance resource in the CloudFormation template.
B. Automate backups by using Amazon Data Lifecycle Manager (Amazon DLM).
C. Create a backup plan in AWS Backup.
D. Set the DeletionPolicy attribute to Retain for the EC2 instance resource in the CloudFormation template.

Answer

D. Set the DeletionPolicy attribute to Retain for the EC2 instance resource in the CloudFormation template.

Explanation

The correct answer is D. Set the DeletionPolicy attribute to Retain for the EC2 instance resource in the CloudFormation template.

AWS CloudFormation is a service that allows you to create and manage AWS resources using code. You can use a CloudFormation template to define the resources and their properties, dependencies, and configurations. You can then create a CloudFormation stack, which is a collection of resources that are created and managed as a single unit.

By default, when you delete a CloudFormation stack, all of the resources in the stack are also deleted. However, you can use the DeletionPolicy attribute to specify how CloudFormation handles the deletion of a specific resource. There are three possible values for the DeletionPolicy attribute:

  • Delete: This is the default value. It means that CloudFormation deletes the resource and all of its data when you delete the stack.
  • Snapshot: This means that CloudFormation creates a snapshot of the resource and its data before deleting it. You can use the snapshot to restore the resource later. This value is only supported for some resources, such as Amazon EBS volumes, Amazon RDS instances, or Amazon Redshift clusters.
  • Retain: This means that CloudFormation keeps the resource and its data when you delete the stack. You can manage the resource independently from CloudFormation after deletion.

Setting the DeletionPolicy attribute to Retain for the EC2 instance resource in the CloudFormation template can meet the requirements because:

  • It can keep the instances and all of the instances’ data, even if someone deletes the stack. The EC2 instances and their attached EBS volumes will not be deleted by CloudFormation. They will remain in your AWS account and you can access them as normal.
  • It does not require any additional services or configurations. You only need to add one line of code to your CloudFormation template to specify the DeletionPolicy attribute for the EC2 instance resource.

The other options are incorrect because:

  • Option A is incorrect because setting the DeletionPolicy attribute to Snapshot for the EC2 instance resource would not keep the instances, only their data. The EC2 instances would be deleted by CloudFormation, but their attached EBS volumes would be snapshotted. You would need to create new EC2 instances and attach the snapshots to them to restore your workload.
  • Option B is incorrect because automating backups by using Amazon Data Lifecycle Manager (Amazon DLM) would not prevent the deletion of the instances or their data. Amazon DLM is a service that allows you to automate the creation, retention, and deletion of EBS snapshots based on policies. However, Amazon DLM does not affect how CloudFormation handles the deletion of resources. You would still need to set the DeletionPolicy attribute to Retain or Snapshot to avoid losing your instances or data when deleting the stack.
  • Option C is incorrect because creating a backup plan in AWS Backup would not prevent the deletion of the instances or their data. AWS Backup is a service that allows you to centrally manage and automate backups of your AWS resources across services. However, AWS Backup does not affect how CloudFormation handles the deletion of resources. You would still need to set the DeletionPolicy attribute to Retain or Snapshot to avoid losing your instances or data when deleting the stack.

Therefore, the best solution to keep the instances and all of the instances’ data, even if someone deletes

Reference

Amazon AWS Certified SysOps Administrator – Associate certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Amazon AWS Certified SysOps Administrator – Associate exam and earn Amazon AWS Certified SysOps Administrator – Associate certification.