AWS Certified DevOps Engineer – Professional — Question 104

A DevOps engineer is setting up a container-based architecture. The engineer has decided to use AWS CloudFormation to automatically provision an Amazon ECS cluster and an Amazon EC2 Auto Scaling group to launch the EC2 container instances. After successfully creating the CloudFormation stack, the engineer noticed that, even though the ECS cluster and the EC2 instances were created successfully and the stack finished the creation, the EC2 instances were associating with a different cluster.

How should the DevOps engineer update the CloudFormation template to resolve this issue?

Answer options

Correct answer: B

Explanation

The correct answer is B because specifying the ECS cluster in the UserData property of the AWS::AutoScaling::LaunchConfiguration ensures that the EC2 instances are properly registered with the intended ECS cluster upon launch. Options A and C do not directly address the registration of instances with the ECS cluster during launch, and option D adds unnecessary complexity by involving a CustomResource and Lambda function, which is not needed for this straightforward registration process.