CloudWatch agent fails to publish logs because the IAM policy grants cloudwatch: instead of logs:
An Amazon EC2 Auto Scaling group launches Amazon Linux EC2 instances and installs the Amazon CloudWatch agent to publish logs to Amazon CloudWatch Logs. The EC2 instances launch with an IAM role that has an IAM policy attached. The policy provides access to publish custom metrics to CloudWatch. The EC2 instances run in a private subnet inside a VPC The VPC provides access to the internet for private subnets through a NAT gateway. A security engineer notices that no logs are being published to CloudWatch Logs for the EC2 instances that the Auto Scaling group launches. The security engineer validates that the CloudWatch Logs agent is running and is configured properly on the EC2 instances. In addition, the security engineer validates that network communications are working properly to AWS services. What can the security engineer do to ensure that the logs are published to CloudWatch Logs?
Community Votes
52% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
CloudWatch Metrics and CloudWatch Logs are separate AWS services with separate IAM namespaces. The metrics namespace is cloudwatch: (e.g., PutMetricData) while the Logs namespace is logs: (e.g., CreateLogGroup, CreateLogStream, PutLogEvents). Granting cloudwatch: does not enable log publishing.
An EC2 Auto Scaling group launches Amazon Linux instances that run the CloudWatch agent to ship logs to CloudWatch Logs. The agent runs and networking is healthy, but no logs arrive. The attached instance role already has cloudwatch: permissions for custom metrics, yet those permissions belong to the CloudWatch Metrics namespace and do not cover the CloudWatch Logs API.
Choosing the option that adds cloudwatch: API actions, because the question mentions the existing policy already covers custom metrics. The agent's log pipeline actually calls the logs: API, so the missing permission is in the logs: namespace, not cloudwatch:.
Community Discussion (18 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The CloudWatch agent publishes log events to the CloudWatch Logs service, which exposes its API under thelogs: namespace (CreateLogGroup, CreateLogStream, PutLogEvents, DescribeLogStreams). The instance role in the scenario already has cloudwatch: permissions for custom metrics, but those permissions do not authorize any Logs API call. Adding logs: actions to the role's policy restores log publishing without touching the network, because the security engineer already validated that connectivity and the agent configuration are fine.Why the Other Options Are Wrong
A is wrong becausecloudwatch: covers metrics only; it does not grant the Logs API actions the agent needs, so logs would still fail to publish. B is wrong because the Auto Scaling service-linked role governs scaling actions (alarms, predictive scaling), not the per-instance agent's log writes; the instances use their own instance role. D is wrong because a VPC interface endpoint is unnecessary here—the engineer confirmed network communications to AWS services work, and the root cause is IAM, not routing.Community Comment Notes
Community discussion split A vs C. The decisive point, repeated by several commenters, is that "cloudwatch: API is for METRIC not the logs" and CloudWatch Logs useslogs:*. One commenter cited the AgentReference doc listing the exact logs: API calls the agent makes. A minority incorrectly insisted on A.
cloudwatch:namespace, notaws logs:; hence this option is misleading and incorrect.