This module implements the needed roles and SSM parameter configuration for setting up CloudWatch agent via the SSM service. The setup only works with instances running in AWS.
- SSM agent must be pre-installed on the instance. (How to install SSM agent in an EC2 instance)[https://docs.aws.amazon.com/systems-manager/latest/userguide/agent-install-al.html]
- Run the module to create the roles that are needed for CloudWatch to forward metrics.
- Attach either the
CloudWatchAgentServerRole
orCloudWatchAgentAdminRole
to the EC2 instance that needs to forward the metrics. - Use SSM run command and choose in the command document list the
AWS-ConfigureAWSPackage
to install CWagent if not already installed. a. In the name box fill inAmazonCloudWatchAgent
- Use SSM run command and choose in the command document list the
AmazonCloudWatchAgent
to configure your CloudWatch Agent. a. In the Action list, choose configure. b. In the Optional Configuration Source list, choose ssm. c. In the Optional Configuration Location box, enter the name of the agent configuration file that you created and saved to Systems Manager Parameter Store. d. In the Optional Restart list, choose yes to start the agent
To use this module ...
module "cw_agent_setup" {
source = "../modules/terraform-aws-module-cloudwatch-agent"
}
- (Install CW agent on EC2 instance fleet)[https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance-fleet.html]
- (CW agent configuration file setup)[https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html]
Name | Version |
---|---|
aws | n/a |
Name | Source | Version |
---|---|---|
cw_admin_role | [email protected]:TechNative-B-V/terraform-aws-module-iam-role.git | 818f7b89e9b98423fb5517f124c80aa847936e98 |
instance_role | [email protected]:TechNative-B-V/terraform-aws-module-iam-role.git | 818f7b89e9b98423fb5517f124c80aa847936e98 |
Name | Type |
---|---|
aws_iam_instance_profile.cw_agent | resource |
aws_iam_instance_profile.cw_agent_admin | resource |
aws_ssm_parameter.cw_config_file | resource |
No inputs.
Name | Description |
---|---|
cw_config_parameter_name | n/a |