Question 497:
A Java application is deployed in an AWS Auto Scaling group. You want to create a Bash script running in each EC2 instance that can periodically perform the health check of the web application. If the health check has failed in the script, the instance should be marked as “Unhealthy” and be replaced by a new instance in the Auto Scaling group. With this script, the application can auto heal when an EC2 instance has an issue. How would you design the Bash script?
Answer options:
A.In the script, use AWS CLI "aws autoscaling set-instance-health" to inform the Auto Scaling group that the instance is unhealthy. The ASG will terminate the instance and recreate a new one. B.In the script, use AWS CLI "aws elbv2 set-instance-health" to inform the Elastic Load Balancer that the instance is unhealthy. The ELB target group will recreate a new instance. C.In the script, use “sudo reboot” to reboot the server if the health check fails. Then the Auto Scaling group will terminate the instance and launch a new one. D.In the script, use AWS CLI "aws autoscaling enter-standby" to inform the Auto Scaling group to put the instance in the standby mode. The ASG will recreate a new instance to replace it.