A company has a legacy application running on AWS. The application can only run on one Amazon EC2 instance at a time. Application metadata is stored in Amazon S3 and must be retrieved if the instance is restarted. The instance should be automatically restarted or relaunched if performance degrades.
Which solution will satisfy these requirements?
A. Create an Amazon CloudWatch alarm to monitor the EC2 instance. When the StatusCheckFailed system alarm is triggered, use the recover action to stop and start the instance. Use a trigger in Amazon S3 to push the metadata to the instance when it is back up and running.
B. Use the auto healing feature in AWS OpsWorks to stop and start the EC2 instance. Use a lifecycle event in OpsWorks to pull the data from Amazon S3 and update it on the instance.
C. Use the Auto Recovery feature in Amazon EC2 to automatically stop and start the EC2 instance in case of a failure. Use a trigger in Amazon S3 to push the metadata to the instance when it is back up and running.
D. Use AWS CloudFormation to create an EC2 instance that includes the user-data property for the EC2
resource. Add a command in user-data to retrieve the application metadata from Amazon S3.
Answer: C
✅ Explanation
✅ C. Use the Auto Recovery feature in Amazon EC2 to automatically stop and start the EC2 instance in case of a failure. Use a trigger in Amazon S3 to push the metadata to the instance when it is back up and running.
🔍 Here's why C is correct:
❗ Requirements:
Only one EC2 instance should be running.
-It should automatically restart or relaunch if there's performance degradation.
-On restart, the instance must retrieve metadata from Amazon S3.
✅ Why Option C fits:
Auto Recovery in EC2 monitors the instance using CloudWatch alarms (based on StatusCheckFailed) and will automatically recover the instance (relaunch it on new hardware if needed).
-Once restarted, you can use an S3 event trigger or a script in user-data to retrieve metadata from Amazon S3.
-It ensures availability and data consistency without launching multiple instances (which is key for legacy apps limited to one instance).
❌ Why the other options are not ideal:
A. CloudWatch alarm with recover action + S3 trigger:
While partially correct, EC2 recover actions only support certain types of hardware failures and do not stop/start instances for software-level performance issues. Also, S3 cannot directly “push” data to EC2. This approach lacks the automation of pulling metadata unless paired with custom solutions.
B. AWS OpsWorks:
Overkill for a single-instance legacy application. OpsWorks is better suited for more complex, multi-instance configurations using Chef or Puppet. Adds unnecessary complexity.
D. CloudFormation with user-data script:
CloudFormation is for provisioning. It does not monitor or auto-recover instances. This option only helps at initial launch, not for ongoing recovery or restarts.
✅ Final Answer:
C. Use the Auto Recovery feature in Amazon EC2 to automatically stop and start the EC2 instance in case of a failure. Use a trigger in Amazon S3 to push the metadata to the instance when it is back up and running.