AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 95

A DevOps engineer has implemented a CI/CD pipeline to deploy an AWS CloudFormation template that provisions a web application. The web application consists of an Application Load Balancer (ALB), a target group, a launch template that uses an Amazon Linux 2 AMI, an Auto Scaling group of Amazon EC2 instances, a security group, and an Amazon RDS for MySQL database. The launch template includes user data that specifies a script to install and start the application.

The initial deployment of the application was successful. The DevOps engineer made changes to update the version of the application with the user data. The CI/CD pipeline has deployed a new version of the template. However, the health checks on the ALB are now failing. The health checks have marked all targets as unhealthy.

During investigation, the DevOps engineer notices that the CloudFormation stack has a status of UPDATE_COMPLETE. However, when the DevOps engineer connects to one of the EC2 instances and checks /var/log/messages, the DevOps engineer notices that the Apache web server failed to start successfully because of a configuration error.

How can the DevOps engineer ensure that the CloudFormation deployment will fail if the user data fails to successfully finish running?

Answer options

Correct answer: A

Explanation

The correct answer is A because using the cfn-signal helper script along with the WaitOnResourceSignals update policy allows CloudFormation to wait for a signal from the EC2 instance indicating whether the user data script was successful or not. If the script fails, the signal will not be sent, causing the stack update to fail. The other options either do not directly address the user data execution success or fail to ensure that CloudFormation is aware of the script's status.