AWS Certified Developer – Associate — Question 312

A company runs an application on Amazon EC2 instances behind an Application Load Balancer. The instances run in an Amazon EC2 Auto Scaling group. The company has configured the Amazon CloudWatch agent to capture custom metrics within the instances. When the company launches new instances, the agent starts successfully, but it does not deliver any custom metrics to CloudWatch.

Which action will deliver the custom metrics to CloudWatch?

Answer options

Correct answer: B

Explanation

To allow the CloudWatch agent on EC2 instances to publish custom metrics, the instances must be associated with an IAM role that has the CloudWatchAgentServerPolicy attached. Options C and D are incorrect because IAM policies cannot be attached directly to a launch template; they must be attached to an IAM role (instance profile) that the template uses. Option A is incorrect because permissions are handled by AWS IAM roles assigned to the EC2 instance, not within the agent's local JSON configuration file.