AWS AmazonCloudWatch: CloudWatch agent prerequisites: network egress, endpoints, and IAM steps
Summary
Rewrites the CloudWatch agent prerequisites page: adds an explicit network-requirements section (HTTPS/TCP 443 egress via internet gateway, NAT gateway, interface VPC endpoints, or proxy, plus a VPC Block Public Access caveat), adds the xray endpoint and a note that an unreachable ec2 endpoint hangs fetch-config, updates the IAM user creation walkthrough to the current console flow with secure access-key handling, and replaces the step-by-step logs:PutRetentionPolicy inline-policy procedures with a note that CloudWatchAgentServerPolicy already grants it. The old standalone Network requirements section is removed (content consolidated above).
Security assessment
The change documents required network paths for agent telemetry (HTTPS 443, NAT/VPC endpoints/proxy) and warns that VPC Block Public Access blocks public-subnet internet egress, which is network-hardening guidance rather than a fix for a specific vulnerability. It also tightens credential-handling wording ('store them securely') and clarifies that the managed CloudWatchAgentServerPolicy already includes logs:PutRetentionPolicy, reducing the risk of over-broad custom inline policies. No CVE or incident is referenced.
Evidence
The CloudWatch agent sends data to AWS service endpoints over HTTPS (port 443). Your servers must be able to reach those endpoints through one of the following:
Diff
diff --git a/AmazonCloudWatch/latest/monitoring/prerequisites.md b/AmazonCloudWatch/latest/monitoring/prerequisites.md index 583c30c..79ca401 100644 --- a//AmazonCloudWatch/latest/monitoring/prerequisites.md +++ b//AmazonCloudWatch/latest/monitoring/prerequisites.md @@ -7 +7 @@ -Required IAM permissionsNetwork requirementsIAM roles and users for CloudWatch agentNetwork requirements +Required IAM permissionsNetwork requirementsIAM roles and users for CloudWatch agent @@ -34,0 +35,17 @@ Error | Likely cause +The CloudWatch agent sends data to AWS service endpoints over HTTPS (port 443). Your servers must be able to reach those endpoints through one of the following: + + * An internet gateway, for Amazon EC2 instances in a public subnet. For more information, see [Internet gateways](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html) in the _Amazon VPC User Guide_. + + * A NAT gateway, for Amazon EC2 instances in a private subnet. For more information, see [NAT gateways](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html) in the _Amazon VPC User Guide_. + + * Interface VPC endpoints, for Amazon EC2 instances without internet access. For more information, see the endpoint list in this section. + + * A proxy server. You specify the proxy in the agent's `common-config.toml` file. + + + + +Note + +If VPC Block Public Access is turned on for your account, instances in a public subnet can't reach the internet through an internet gateway, even if they have a public IP address. In ingress-only mode, only traffic through NAT gateways and egress-only internet gateways is allowed. Use a NAT gateway, VPC endpoints, or a Block Public Access exclusion. For more information, see [Block public access to VPCs and subnets](https://docs.aws.amazon.com/vpc/latest/userguide/security-vpc-bpa.html) in the _Amazon VPC User Guide_. + @@ -39 +56 @@ The agent must reach the following endpoints over HTTPS (TCP 443): - * `ec2.`region`.amazonaws.com`: for EC2 instance tag lookups used by the agent + * `ec2.`region`.amazonaws.com`: for EC2 instance tag lookups used by the agent. If the agent can't reach this endpoint, the `fetch-config` command stops responding before the agent starts. @@ -58,0 +76,2 @@ You might also need these endpoints: + * `xray.`region`.amazonaws.com`: to send traces, or to use Application Signals. + @@ -98,2 +116,0 @@ If you're going to run the CloudWatch agent on Amazon EC2 instances, create an I -(Optional) If the agent is going to send logs to CloudWatch Logs and you want the agent to be able to set retention policies for these log groups, you need to add the `logs:PutRetentionPolicy` permission to the role. - @@ -110 +127,3 @@ This scenario requires IAM users with programmatic access and long-term credenti - 2. In the navigation pane, choose **Users** and then **Add users**. + 2. In the navigation pane, choose **Users** and then **Create user**. + + 3. Enter the user name for the new user and choose **Next**. @@ -112 +131 @@ This scenario requires IAM users with programmatic access and long-term credenti - 3. Enter the user name for the new user. Select **Access key - Programmatic access** and choose **Next: Permissions**. + 4. Choose **Attach policies directly**. @@ -114 +133 @@ This scenario requires IAM users with programmatic access and long-term credenti - 4. Choose **Attach existing policies directly**. + 5. In the list of policies, select the check box next to **CloudWatchAgentServerPolicy**. If necessary, use the search box to find the policy. Choose **Next**. @@ -116 +135 @@ This scenario requires IAM users with programmatic access and long-term credenti - 5. In the list of policies, select the check box next to **CloudWatchAgentServerPolicy**. If necessary, use the search box to find the policy. Choose **Next: Tags**. + 6. (Optional) Add tags for the new IAM user. Confirm that the correct policy is listed and choose **Create user**. @@ -118 +137 @@ This scenario requires IAM users with programmatic access and long-term credenti - 6. (Optional) Create tags for the new IAM user. Choose **Next: Review**. Confirm that the correct policy is listed and choose **Create user**. + 7. Choose the name of the new user, and then choose the **Security credentials** tab. @@ -120 +139,3 @@ This scenario requires IAM users with programmatic access and long-term credenti - 7. Next to the name of the new user, choose **Show**. Copy the access key and secret key to a file so that you can use them when installing the agent. Choose **Close**. + 8. Under **Access keys** , choose **Create access key**. For **Use case** , choose **Application running outside AWS** , and then choose **Next**. + + 9. Choose **Create access key**. Copy the access key and secret access key and store them securely so that you can use them when installing the agent. Choose **Done**. For more information, see [Manage access keys for IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) in the _IAM User Guide_. @@ -129 +150 @@ To enable the CloudWatch agent to send data from an Amazon EC2 instance, you mus -For more information about attaching an IAM role to an instance, see [Attaching an IAM Role to an Instance](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/iam-roles-for-amazon-ec2.html#attach-iam-role) in the Amazon Elastic Compute Cloud User Guide. +For more information about attaching an IAM role to an instance, see [Attach an IAM role to an instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/attach-iam-role.html) in the Amazon Elastic Compute Cloud User Guide. @@ -133,11 +154 @@ For more information about attaching an IAM role to an instance, see [Attaching -You can configure the CloudWatch agent to set the retention policy for log groups that it sends log events to. If you do this, you must grant the `logs:PutRetentionPolicy` to the IAM role or user that the agent uses. The agent uses an IAM role to run on Amazon EC2 instances, and uses an IAM user for on-premises servers. - -###### To grant log retention permissions to the agent's IAM role - - 1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). - - 2. In the left navigation pane, choose **Roles**. - - 3. In the search box, enter the beginning of the name of the CloudWatch agent's IAM role. You chose this name when you created the role. It might be named `CloudWatchAgentServerRole`. - -When you see the role, choose the name of the role. +You can configure the CloudWatch agent to set the retention policy for log groups that it sends log events to. To do this, the IAM role or user that the agent uses must have the `logs:PutRetentionPolicy` permission. The **CloudWatchAgentServerPolicy** managed policy includes this permission, so you don't need to take any further action if you attached that policy. @@ -145,3 +156 @@ When you see the role, choose the name of the role. - 4. In the **Permissions** tab, choose **Add permissions** , **Create inline policy**. - - 5. Choose the **JSON** tab and copy the following policy into the box, replacing the default JSON in the box: +If you use a custom policy instead of **CloudWatchAgentServerPolicy** , grant the permission with a policy like the following: @@ -155,38 +163,0 @@ JSON - { - "Version":"2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": "logs:PutRetentionPolicy", - "Resource": "*" - } - ] - } - - - 6. Choose **Review policy**. - - 7. For **Name** , enter `CloudWatchAgentPutLogsRetention` or something similar, and choose **Create policy**. - - - - -###### To grant log retention permissions to the agent's IAM user - - 1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). - - 2. In the left navigation pane, choose **Users**. - - 3. In the search box, enter the beginning of the name of the CloudWatch agent's IAM user. You chose this name when you created the user. - -When you see the user, choose the name of the user. - - 4. In the **Permissions** tab, choose **Add inline policy**. - - 5. Choose the **JSON** tab and copy the following policy into the box, replacing the default JSON in the box: - -JSON - - -**** - @@ -206,30 +176,0 @@ JSON - 6. Choose **Review policy**. - - 7. For **Name** , enter `CloudWatchAgentPutLogsRetention` or something similar, and choose **Create policy**. - - - - -## Network requirements - -Note - -When the server is in a public subnet make sure there is access to an internet gateway. When the server is in a private subnet, access is through the NAT gateways or VPC Endpoint. For more information about NAT gateways, see <https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html>. - -Your Amazon EC2 instances must have outbound internet access to send data to CloudWatch or CloudWatch Logs. For more information about how to configure internet access, see [Internet Gateways](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html) in the Amazon VPC User Guide. - -### Using VPC endpoints - -If you're using a VPC and want to use CloudWatch agent without public internet access, you can configure VPC endpoints for CloudWatch and CloudWatch Logs. - -The endpoints and ports to configure on your proxy are as follows: - - * If you're using the agent to collect metrics, you must add the CloudWatch endpoints for the appropriate Regions to the allow list. These endpoints are listed in [Amazon CloudWatch endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/cw_region.html). - - * If you're using the agent to collect logs, you must add the CloudWatch Logs endpoints for the appropriate Regions to the allow list. These endpoints are listed in [Amazon CloudWatch Logs endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/cwl_region.html). - - * If you're using Systems Manager to install the agent or Parameter Store to store your configuration file, you must add the Systems Manager endpoints for the appropriate Regions to the allow list. These endpoints are listed in [AWS Systems Manager endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/ssm.html). - - - -