Question 22
Domain 4: Monitoring and LoggingA company runs an application on one Amazon EC2 instance. Application metadata is stored in Amazon S3 and must be retrieved if the instance is restarted. The instance must restart or relaunch automatically if the instance becomes unresponsive. Which solution will meet these requirements?
Correct answer: B
Explanation
AWS OpsWorks auto healing monitors instance health and can "stop and start the instance" when it becomes unresponsive, satisfying the restart/relaunch requirement. A lifecycle event can run code during setup or configuration to "pull the metadata from Amazon S3 and update it on the instance," so the application state is restored after recovery.
Why each option is right or wrong
A. Create an Amazon CloudWatch alarm for the StatusCheckFailed metric. Use the recover action to stop and start the instance. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
CloudWatch recovery actions address infrastructure health, but S3 notifications do not reliably drive instance-side restore logic.
B. Configure AWS OpsWorks, and use the auto healing feature to stop and start the instance. Use a lifecycle event in OpsWorks to pull the metadata from Amazon S3 and update it on the instance.
AWS OpsWorks supports auto healing for registered instances: when an instance is marked unhealthy or unresponsive, OpsWorks can automatically stop and start it to recover service. In addition, OpsWorks lifecycle events such as Setup/Configure can run custom scripts on the instance, which is the point at which the application can retrieve its metadata from Amazon S3 and write it back locally after the restart/relaunch.
C. Use EC2 Auto Recovery to automatically stop and start the instance in case of a failure. Use an S3 event notification to push the metadata to the instance when the instance is back up and running.
EC2 Auto Recovery focuses on host recovery, not application lifecycle steps like reloading metadata after restart.
D. Use AWS CloudFormation to create an EC2 instance that includes the UserData property for the EC2 resource. Add a command in UserData to retrieve the application metadata from Amazon S3.
User data is mainly for launch-time bootstrapping, not ongoing health-based restart or relaunch automation.