FEATURES PRICING ABOUT DOCS LOGIN

aws_cloudwatch_metric_alarm

Provides a CloudWatch Metric Alarm resource.

Example Usage

resource "aws_cloudwatch_metric_alarm" "foobar" {
    alarm_name = "terraform-test-foobar5"
    comparison_operator = "GreaterThanOrEqualToThreshold"
    evaluation_periods = "2"
    metric_name = "CPUUtilization"
    namespace = "AWS/EC2"
    period = "120"
    statistic = "Average"
    threshold = "80"
    alarm_description = "This metric monitor ec2 cpu utilization"
    insufficient_data_actions = []
}

Example in Conjunction with Scaling Policies

resource "aws_autoscaling_policy" "bat" {
    name = "foobar3-terraform-test"
    scaling_adjustment = 4
    adjustment_type = "ChangeInCapacity"
    cooldown = 300
    autoscaling_group_name = "${aws_autoscaling_group.bar.name}"
}

resource "aws_cloudwatch_metric_alarm" "bat" {
    alarm_name = "terraform-test-foobar5"
    comparison_operator = "GreaterThanOrEqualToThreshold"
    evaluation_periods = "2"
    metric_name = "CPUUtilization"
    namespace = "AWS/EC2"
    period = "120"
    statistic = "Average"
    threshold = "80"
    dimensions {
        AutoScalingGroupName = "${aws_autoscaling_group.bar.name}"
    }
    alarm_description = "This metric monitor ec2 cpu utilization"
    alarm_actions = ["${aws_autoscaling_policy.bat.arn}"]
}

Argument Reference

See related part of AWS Docs for details about valid values.

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Import

Cloud Metric Alarms can be imported using the alarm_name, e.g.

$ terraform import aws_cloudwatch_metric_alarm.test alarm-12345

See the source of this document at Terraform.io

REQUEST A DEMO