AWS AmazonCloudWatch: CloudWatch agent CloudFormation tutorial: AL2023, OTLP, SSH/IAM guidance
Summary
Updates the CloudWatch agent CloudFormation install tutorial: switches Amazon Linux 2 references to AL2023, updates CloudFormation console UI wording, adds an OpenTelemetry (OTLP) configuration note, clarifies the IAMRole parameter (instance profile with CloudWatchAgentServerPolicy), adds a SubnetId parameter, replaces the rpm/ps verification commands with the agent-ctl status command, and adds a recommendation to restrict the SSHLocation CIDR instead of leaving the 0.0.0.0/0 default.
Security assessment
The diff is primarily a documentation refresh (AL2 to AL2023, console label changes, OTLP note, status command). The only security-relevant addition is explicit guidance that the SSHLocation default 0.0.0.0/0 exposes SSH to any IP and should be restricted to the operator's addresses, plus clarification that the IAMRole must be an instance profile carrying CloudWatchAgentServerPolicy. This is hardening/best-practice guidance, not a fix for a specific vulnerability or incident, so it is medium severity and not security_issue_related.
Evidence
* **SSHLocation** : Specifies the IP address range that can be used to connect to the instance using SSH. The default, `0.0.0.0/0`, allows access from any IP address. We recommend that you restrict this range to the IP addresses that you connect from.
Diff
diff --git a/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent-New-Instances-CloudFormation.md b/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent-New-Instances-CloudFormation.md index 668d95b..bad5050 100644 --- a//AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent-New-Instances-CloudFormation.md +++ b//AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent-New-Instances-CloudFormation.md @@ -50 +50,3 @@ In the inline templates, all placeholder variables must have an exclamation mark - * The templates in the `ssm` directory load an agent configuration file from Parameter Store. To use these templates, you must first create a configuration file and upload it to Parameter Store. You then provide the Parameter Store name of the file in the template. You can create the configuration file manually or by using the wizard. For more information, see [Create the CloudWatch agent configuration file](./create-cloudwatch-agent-configuration-file.html). +To have the agent receive OpenTelemetry Protocol (OTLP) data from your applications, add an `opentelemetry` section to the agent configuration. For more information, see [Amazon CloudWatch agent](./CloudWatch-OTLPCloudWatchAgent.html). + + * The templates in the `ssm` directory load an agent configuration file from Parameter Store. To use these templates, you must first create a configuration file and upload it to Parameter Store. You then provide the Parameter Store name of the file in the template. You can create the configuration file manually or by using the wizard. For more information, see [Create the Classic CloudWatch agent configuration file](./create-cloudwatch-agent-configuration-file.html). @@ -61 +63 @@ For information about setting up the agent on a system that has security-enhance -This tutorial walks you through using CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running Amazon Linux 2 using the inline templates, which don't require the use of the JSON configuration file or Parameter Store. The inline template includes the agent configuration in the template. In this tutorial, you use the default agent configuration contained in the template. +This tutorial walks you through using CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running AL2023 using the inline templates, which don't require the use of the JSON configuration file or Parameter Store. The inline template includes the agent configuration in the template. In this tutorial, you use the default agent configuration contained in the template. @@ -67 +69 @@ After the procedure for installing the agent, the tutorial continues with how to - 1. Download the template from GitHub. In this tutorial, download the inline template for Amazon Linux 2 as follows: + 1. Download the template from GitHub. In this tutorial, download the inline template for Amazon Linux as follows: @@ -73 +75 @@ After the procedure for installing the agent, the tutorial continues with how to - 3. Choose **Create stack**. + 3. Choose **Create stack** , **With new resources (standard)**. @@ -75 +77 @@ After the procedure for installing the agent, the tutorial continues with how to - 4. For **Choose a template** , select **Upload a template to Amazon S3** , choose the downloaded template, and choose **Next**. + 4. For **Prepare template** , choose **Choose an existing template**. For **Specify template** , choose **Upload a template file** , choose the downloaded template, and choose **Next**. @@ -77 +79 @@ After the procedure for installing the agent, the tutorial continues with how to - 5. On the **Specify Details** page, fill out the following parameters and choose **Next** : + 5. On the **Specify stack details** page, fill out the following parameters and choose **Next** : @@ -81 +83 @@ After the procedure for installing the agent, the tutorial continues with how to - * **IAMRole** : Choose an IAM role that has permissions to write CloudWatch metrics, logs, and traces. For more information, see [Prerequisites](./prerequisites.html). + * **IAMRole** : Enter the name of the instance profile for an IAM role that has the **CloudWatchAgentServerPolicy** policy attached. When you create a role for Amazon EC2 in the IAM console, the console creates an instance profile with the same name as the role. For more information, see [Prerequisites](./prerequisites.html). @@ -83 +85 @@ After the procedure for installing the agent, the tutorial continues with how to - * **InstanceAMI** : Choose an AMI that is valid in the Region where you're going to launch your stack. + * **InstanceAMI** : Keep the default, which is a public Parameter Store parameter that resolves to the latest AL2023 AMI in the Region where you launch your stack. @@ -89 +91,3 @@ After the procedure for installing the agent, the tutorial continues with how to - * **SSHLocation** : Specifies the IP address range that can be used to connect to the instance using SSH. The default allows access from any IP address. + * **SSHLocation** : Specifies the IP address range that can be used to connect to the instance using SSH. The default, `0.0.0.0/0`, allows access from any IP address. We recommend that you restrict this range to the IP addresses that you connect from. + + * **SubnetId** : Choose the subnet to launch the instance in. The instance must be able to reach the CloudWatch endpoints. For more information, see [Network requirements](./prerequisites.html#CloudWatch-Agent-network-requirements). @@ -91 +95 @@ After the procedure for installing the agent, the tutorial continues with how to - 6. On the **Options** page, you can choose to tag your stack resources. Choose **Next**. + 6. On the **Configure stack options** page, you can choose to tag your stack resources. Choose **Next**. @@ -93 +97 @@ After the procedure for installing the agent, the tutorial continues with how to - 7. On the **Review** page, review your information, acknowledge that the stack might create IAM resources, and then choose **Create**. + 7. On the **Review and create** page, review your information, and then choose **Submit**. @@ -99,3 +103 @@ If you refresh the console, you see that the new stack has the `CREATE_IN_PROGRE -Use the following command to confirm that the agent is installed: - - rpm -qa amazon-cloudwatch-agent +Use the following command to confirm that the agent is installed and running: @@ -103 +105 @@ Use the following command to confirm that the agent is installed: -Use the following command to confirm that the agent is running: + sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status @@ -105 +107 @@ Use the following command to confirm that the agent is running: - ps aux | grep amazon-cloudwatch-agent +The output shows the agent status, such as `"status": "running"`, and the agent version. @@ -126 +128 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 3. On the CloudFormation dashboard, select the stack that you created and choose **Update Stack**. + 3. On the **Stacks** page, select the stack that you created and choose **Update**. @@ -128 +130 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 4. For **Select Template** , select **Upload a template to Amazon S3** , choose the template that you modified, and choose **Next**. + 4. Choose **Replace existing template**. For **Specify template** , choose **Upload a template file** , choose the template that you modified, and choose **Next**. @@ -130 +132 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 5. On the **Options** page, choose **Next** and then **Next**. + 5. On the **Specify stack details** and **Configure stack options** pages, choose **Next**. @@ -132 +134 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 6. On the **Review** page, review your information and choose **Update**. + 6. On the review page, review your information and choose **Update stack**. @@ -141 +143 @@ After some time, you see `UPDATE_COMPLETE`. -This tutorial walks you through using CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running Amazon Linux 2 using an agent configuration file that you create and save in Parameter Store. +This tutorial walks you through using CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running AL2023 using an agent configuration file that you create and save in Parameter Store. @@ -149 +151 @@ After the procedure for installing the agent, the tutorial continues with how to - 2. Create the agent configuration file and save it in Parameter Store. For more information, see [Create the CloudWatch agent configuration file](./create-cloudwatch-agent-configuration-file.html). + 2. Create the agent configuration file and save it in Parameter Store. For more information, see [Create the Classic CloudWatch agent configuration file](./create-cloudwatch-agent-configuration-file.html). @@ -153 +155 @@ After the procedure for installing the agent, the tutorial continues with how to - curl -O https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/solutions/AmazonCloudWatchAgent/ssm/amazon_linux.template + curl -O https://raw.githubusercontent.com/aws-cloudformation/aws-cloudformation-templates/main/Solutions/AmazonCloudWatchAgent/ssm/amazon_linux.yaml @@ -157 +159 @@ After the procedure for installing the agent, the tutorial continues with how to - 5. Choose **Create stack**. + 5. Choose **Create stack** , **With new resources (standard)**. @@ -159 +161 @@ After the procedure for installing the agent, the tutorial continues with how to - 6. For **Choose a template** , select **Upload a template to Amazon S3** , choose the template that you downloaded, and choose **Next**. + 6. For **Prepare template** , choose **Choose an existing template**. For **Specify template** , choose **Upload a template file** , choose the template that you downloaded, and choose **Next**. @@ -161 +163 @@ After the procedure for installing the agent, the tutorial continues with how to - 7. On the **Specify Details** page, fill out the following parameters accordingly and choose **Next** : + 7. On the **Specify stack details** page, fill out the following parameters accordingly and choose **Next** : @@ -165 +167 @@ After the procedure for installing the agent, the tutorial continues with how to - * **IAMRole** : Choose an IAM role that has permissions to write CloudWatch metrics, logs, and traces. For more information, see [Prerequisites](./prerequisites.html). + * **IAMRole** : Enter the name of the instance profile for an IAM role that has the **CloudWatchAgentServerPolicy** policy attached. When you create a role for Amazon EC2 in the IAM console, the console creates an instance profile with the same name as the role. For more information, see [Prerequisites](./prerequisites.html). @@ -167 +169 @@ After the procedure for installing the agent, the tutorial continues with how to - * **InstanceAMI** : Choose an AMI that is valid in the Region where you're going to launch your stack. + * **InstanceAMI** : Keep the default, which is a public Parameter Store parameter that resolves to the latest AL2023 AMI in the Region where you launch your stack. @@ -173 +175,3 @@ After the procedure for installing the agent, the tutorial continues with how to - * **SSHLocation** : Specifies the IP address range that can be used to connect to the instance using SSH. The default allows access from any IP address. + * **SSHLocation** : Specifies the IP address range that can be used to connect to the instance using SSH. The default, `0.0.0.0/0`, allows access from any IP address. We recommend that you restrict this range to the IP addresses that you connect from. + + * **SubnetId** : Choose the subnet to launch the instance in. The instance must be able to reach the CloudWatch endpoints. For more information, see [Network requirements](./prerequisites.html#CloudWatch-Agent-network-requirements). @@ -177 +181 @@ After the procedure for installing the agent, the tutorial continues with how to - 8. On the **Options** page, you can choose to tag your stack resources. Choose **Next**. + 8. On the **Configure stack options** page, you can choose to tag your stack resources. Choose **Next**. @@ -179 +183 @@ After the procedure for installing the agent, the tutorial continues with how to - 9. On the **Review** page, review your information, acknowledge that the stack might create IAM resources, and then choose **Create**. + 9. On the **Review and create** page, review your information, and then choose **Submit**. @@ -185,3 +189 @@ If you refresh the console, you see that the new stack has the `CREATE_IN_PROGRE -Use the following command to confirm that the agent is installed: - - rpm -qa amazon-cloudwatch-agent +Use the following command to confirm that the agent is installed and running: @@ -189 +191 @@ Use the following command to confirm that the agent is installed: -Use the following command to confirm that the agent is running: + sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status @@ -191 +193 @@ Use the following command to confirm that the agent is running: - ps aux | grep amazon-cloudwatch-agent +The output shows the agent status, such as `"status": "running"`, and the agent version. @@ -206 +208 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 4. On the CloudFormation dashboard, select the stack that you created and choose **Update Stack**. + 4. On the **Stacks** page, select the stack that you created and choose **Update**. @@ -208 +210 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 5. For **Select Template** , select **Upload a template to Amazon S3** , select the template that you just modified, and choose **Next**. + 5. Choose **Replace existing template**. For **Specify template** , choose **Upload a template file** , choose the template that you modified, and choose **Next**. @@ -210 +212 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 6. On the **Options** page, choose **Next** and then **Next**. + 6. On the **Specify stack details** and **Configure stack options** pages, choose **Next**. @@ -212 +214 @@ The next procedure demonstrates using CloudFormation to update the CloudWatch ag - 7. On the **Review** page, review your information and choose **Update**. + 7. On the review page, review your information and choose **Update stack**. @@ -229 +231 @@ If you use CloudFormation to update your CloudWatch agent configuration, and use -If you don't see metrics that you expect to see after installing or updating the agent, confirm that the agent is configured to collect that metric. To do this, check the `amazon-cloudwatch-agent.json` file to make sure that the metric is listed, and check that you are looking in the correct metric namespace. For more information, see [CloudWatch agent files and locations](./troubleshooting-CloudWatch-Agent.html#CloudWatch-Agent-files-and-locations). +If you don't see metrics that you expect to see after installing or updating the agent, confirm that the agent is configured to collect that metric. To do this, check the `amazon-cloudwatch-agent.json` file to make sure that the metric is listed. For metrics that the agent publishes as CloudWatch metrics, check that you are looking in the correct metric namespace. OpenTelemetry metrics don't use a namespace; query them by metric name with PromQL. For more information, see [CloudWatch agent files and locations](./troubleshooting-CloudWatch-Agent.html#CloudWatch-Agent-files-and-locations). @@ -237 +239 @@ To use the Amazon Web Services Documentation, Javascript must be enabled. Please -Install the CloudWatch agent on Google Cloud +With AWS Systems Manager