github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: cloudwatch_metric_alarm" 4 sidebar_current: "docs-aws-resource-cloudwatch-metric-alarm" 5 description: |- 6 Provides an AutoScaling Scaling Group resource. 7 --- 8 9 # aws\_cloudwatch\_metric\_alarm 10 11 Provides a CloudWatch Metric Alarm resource. 12 13 ## Example Usage 14 ``` 15 resource "aws_cloudwatch_metric_alarm" "foobar" { 16 alarm_name = "terraform-test-foobar5" 17 comparison_operator = "GreaterThanOrEqualToThreshold" 18 evaluation_periods = "2" 19 metric_name = "CPUUtilization" 20 namespace = "AWS/EC2" 21 period = "120" 22 statistic = "Average" 23 threshold = "80" 24 alarm_description = "This metric monitor ec2 cpu utilization" 25 insufficient_data_actions = [] 26 } 27 ``` 28 29 ## Example in Conjunction with Scaling Policies 30 ``` 31 resource "aws_autoscaling_policy" "bat" { 32 name = "foobar3-terraform-test" 33 scaling_adjustment = 4 34 adjustment_type = "ChangeInCapacity" 35 cooldown = 300 36 autoscaling_group_name = "${aws_autoscaling_group.bar.name}" 37 } 38 39 resource "aws_cloudwatch_metric_alarm" "bat" { 40 alarm_name = "terraform-test-foobar5" 41 comparison_operator = "GreaterThanOrEqualToThreshold" 42 evaluation_periods = "2" 43 metric_name = "CPUUtilization" 44 namespace = "AWS/EC2" 45 period = "120" 46 statistic = "Average" 47 threshold = "80" 48 49 dimensions { 50 AutoScalingGroupName = "${aws_autoscaling_group.bar.name}" 51 } 52 53 alarm_description = "This metric monitor ec2 cpu utilization" 54 alarm_actions = ["${aws_autoscaling_policy.bat.arn}"] 55 } 56 ``` 57 58 ~> **NOTE:** You cannot create a metric alarm consisting of both `statistic` and `extended_statistic` parameters. 59 You must choose one or the other 60 61 ## Argument Reference 62 63 See [related part of AWS Docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html) 64 for details about valid values. 65 66 The following arguments are supported: 67 68 * `alarm_name` - (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account 69 * `comparison_operator` - (Required) The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported: `GreaterThanOrEqualToThreshold`, `GreaterThanThreshold`, `LessThanThreshold`, `LessThanOrEqualToThreshold`. 70 * `evaluation_periods` - (Required) The number of periods over which data is compared to the specified threshold. 71 * `metric_name` - (Required) The name for the alarm's associated metric. 72 See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 73 * `namespace` - (Required) The namespace for the alarm's associated metric. See docs for the [list of namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html). 74 See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 75 * `period` - (Required) The period in seconds over which the specified `statistic` is applied. 76 * `statistic` - (Optional) The statistic to apply to the alarm's associated metric. 77 Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` 78 * `threshold` - (Required) The value against which the specified statistic is compared. 79 * `actions_enabled` - (Optional) Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to `true`. 80 * `alarm_actions` - (Optional) The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Number (ARN). 81 * `alarm_description` - (Optional) The description for the alarm. 82 * `dimensions` - (Optional) The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation [here](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 83 * `insufficient_data_actions` - (Optional) The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Number (ARN). 84 * `ok_actions` - (Optional) The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN). 85 * `unit` - (Optional) The unit for the alarm's associated metric. 86 * `extended_statistic` - (Optional) The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100. 87 88 ## Attributes Reference 89 90 The following attributes are exported: 91 92 * `id` - The ID of the health check 93 94 95 ## Import 96 97 Cloud Metric Alarms can be imported using the `alarm_name`, e.g. 98 99 ``` 100 $ terraform import aws_cloudwatch_metric_alarm.test alarm-12345 101 ```