Skip to content

tothenew/terraform-aws-cloudwatch-alarm

terraform-aws-cloudwatch-alarm

Lint Status
LICENSE

This is a template to use for baseline. The default actions will provide updates for section between Requirements and Outputs.

Introduction

This Terraform module provides a standardized way to set up and monitor various AWS resources using CloudWatch metrics. It simplifies the integration of CloudWatch monitoring for EC2 instances and Load Balancers by encapsulating commonly used configurations into reusable modules.

Explanation of Module

The module is structured to include CloudWatch metric alarms for CPU utilization, disk usage, memory usage, and instance status for EC2 instances. It also includes monitoring for ALB request counts, target response times, and unhealthy host counts.

Resources Created and Managed by this Module

This module creates and manages the following types of resources:

  • CloudWatch alarms for:
    • EC2 CPU utilization
    • EC2 disk usage
    • EC2 memory usage
    • EC2 instance status checks
    • ALB request count
    • ALB target response time
    • ALB unhealthy hosts
  • CloudWatch Agent setup for EC2 instances

Example Usages

module "cloudwatch-monitoring" {
  source = "git::https://github.com/tothenew/terraform-aws-cloudwatch-alarm"

  instance_id = ["i-000000000"]
  alb_names   = ["test-1"]
  target_group_name = ["test-tg"]
  requests = true

  loadbalancers = {
    alb1 = {
      name         = "test-1"
      target_group = "test-tg"
      az           = "us-east-1a"
    }
  }
}

Requirements

Name Version
terraform >= 1.3.0

Providers

No providers.

Modules

Name Source Version
agent ./module/ec2-cw-agent/ n/a
ec2-CloudWatch-cpu ./module/ec2-cw/cpu n/a
ec2-CloudWatch-disk ./module/ec2-cw/disk n/a
ec2-CloudWatch-memory ./module/ec2-cw/memory n/a
ec2-CloudWatch-status ./module/ec2-cw/status n/a
lb_request ./module/load-balancer/requestCount/ n/a
lb_target_response_time ./module/load-balancer/targetresponsetime/ n/a
unhealthyhost ./module/load-balancer/unhealthyHost/ n/a

Resources

No resources.

Inputs

Name Description Type Default Required
alb_names n/a list(string)
[
"test-1"
]
no
instance_id n/a list(string)
[
"i-08ef9201037dd01da"
]
no
loadbalancers n/a
map(object({
name = string
target_group = string
az = string
}))
n/a yes
requests n/a bool true no
target_group_name n/a list(string)
[
"test-tg"
]
no

Outputs

No outputs.

Authors

Module managed by TO THE NEW Pvt. Ltd.

License

Apache 2 Licensed. See LICENSE for full details.

About

Create Cloud Alarm of EC2 Instances, Load Balancer, RDS etc.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages