A SysOps Administrator is troubleshooting an Amazon EC2 instance in a private subnet that is unable to send application logs to Amazon CloudWatch Logs. The unified CloudWatch agent is installed on the instance, and an interface VPC endpoint for CloudWatch Logs (`com.amazonaws.us-east-1.logs`) is deployed in the VPC. The CloudWatch agent log file on the instance shows repeated connection timeouts when attempting to reach the CloudWatch Logs service endpoint.
Which TWO configurations should the administrator verify to resolve these connection timeouts? (Select TWO.)
- Verify that the security group attached to the interface VPC endpoint allows inbound TCP port 443 traffic from the security group of the EC2 instance.Answer
- Verify that the VPC has both 'Enable DNS resolution' and 'Enable DNS hostnames' set to true to ensure the standard CloudWatch Logs service endpoint resolves to the private IP addresses of the interface VPC endpoint.Answer
- CVerify that the EC2 instance profile has the `iam:PassRole` permission to pass the CloudWatch agent service role to the interface VPC endpoint.
- DVerify that the Amazon S3 bucket policy associated with the VPC gateway endpoint allows the `s3:PutObject` action from the EC2 instance profile role.
- EVerify that the retention policy of the destination CloudWatch log group is set to 'Never Expire' to allow the agent to initialize a new log stream.
Answer
Verify that the security group attached to the interface VPC endpoint allows inbound TCP port 443 traffic from the EC2 instance's security group, and verify that the VPC has 'Enable DNS resolution' and 'Enable DNS hostnames' set to true.
The connection timeouts indicate that the CloudWatch agent is unable to reach the CloudWatch Logs service endpoint. Because the EC2 instance is located in a private subnet without internet access, it must use the interface VPC endpoint (`com.amazonaws.us-east-1.logs`) to route its traffic privately. To achieve this, two conditions must be met: first, the security group of the VPC endpoint must permit inbound HTTPS (port 443) traffic from the EC2 instance's security group. Second, the VPC must have both 'Enable DNS resolution' and 'Enable DNS hostnames' enabled so that the standard CloudWatch Logs regional domain (e.g., `logs.us-east-1.amazonaws.com`) resolves to the private IP addresses of the interface endpoint instead of the public internet addresses.
Step-by-Step Solution
Key Concept
VPC Endpoint Connectivity and Private DNS Resolution for CloudWatch Logs