This module creates AWS CloudWatch Alarms for AWS EC2 Instance Metrics.
# main.tf
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
resource "aws_security_group" "this" {
name = "SG EC2 - ${local.name}"
vpc_id = local.vpc_id
lifecycle {
create_before_destroy = true
}
}
module "ec2_instance" {
source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_ec2_instance"
name = local.name
type = local.instance_type
ami = local.ami_id
vpc_id = local.vpc_id
subnet_id = local.subnet_group_subnet_id
has_elastic_ip = false
security_group_id = aws_security_group.this.id
extra_sg_ids = [ local.vpc_sg_id ]
}
module "ec2_instance_alarms" {
source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_ec2_instance_alarms"
name_prefix = "${local.zone}-"
ec2_instance_id = module.ec2_instance.id
ec2_instance_codename = local.codename
sns_topic_arns = local.notification_sns_topic_arn
}
Name | Version |
---|---|
terraform | < 2.0.0, >= 1.6.6 |
aws | < 6.0, >= 5.22 |
Name | Description | Type | Default | Required |
---|---|---|---|---|
name_prefix | Prefix for CloudWatch alarms names | string |
"" |
no |
ec2_instance_id | Instance ID alarms will be created for | string |
n/a | yes |
ec2_instance_codename | Instance Codename for CloudWatch alarms names | string |
n/a | yes |
sns_topic_arns | SNS Topic ARNs attached to CloudWatch alarms | list(string) |
n/a | yes |
evaluation_periods | Evaluation period over which to use when triggering alarms | number |
5 |
no |
statistics_period | Number of seconds that make each statistic period | number |
60 |
no |
enable_cpu_utilization_alarms | Create CPU Utilization alarms | bool |
true |
no |
cpu_utilization_too_high_threshold | Percentage threshold of CPU utilization alarm | number |
80 |
no |
Name | Description |
---|---|
cpu_utilization_too_high_alarm_arn | 'CPU Utilization Too High' alarm's ARN |
cpu_utilization_too_high_alarm_name | 'CPU Utilization Too High' alarm's Name |
cpu_utilization_too_high_alarm_threshold | 'CPU Utilization Too High' alarm's Threshold |
Name | Type |
---|---|
aws_cloudwatch_metric_alarm.this | resource |