github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/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 dimensions { 49 AutoScalingGroupName = "${aws_autoscaling_group.bar.name}" 50 } 51 alarm_description = "This metric monitor ec2 cpu utilization" 52 alarm_actions = ["${aws_autoscaling_policy.bat.arn}"] 53 } 54 ``` 55 56 ~> **NOTE:** You cannot create a metric alarm consisting of both `statistic` and `extended_statistic` parameters. 57 You must choose one or the other 58 59 ## Argument Reference 60 61 See [related part of AWS Docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html) 62 for details about valid values. 63 64 The following arguments are supported: 65 66 * `alarm_name` - (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account 67 * `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`. 68 * `evaluation_periods` - (Required) The number of periods over which data is compared to the specified threshold. 69 * `metric_name` - (Required) The name for the alarm's associated metric. 70 See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 71 * `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). 72 See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 73 * `period` - (Required) The period in seconds over which the specified `statistic` is applied. 74 * `statistic` - (Optional) The statistic to apply to the alarm's associated metric. 75 Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` 76 * `threshold` - (Required) The value against which the specified statistic is compared. 77 * `actions_enabled` - (Optional) Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to `true`. 78 * `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). 79 * `alarm_description` - (Optional) The description for the alarm. 80 * `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). 81 * `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). 82 * `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). 83 * `unit` - (Optional) The unit for the alarm's associated metric. 84 * `extended_statistic` - (Optional) The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100. 85 86 ## Attributes Reference 87 88 The following attributes are exported: 89 90 * `id` - The ID of the health check 91 92 93 ## Import 94 95 Cloud Metric Alarms can be imported using the `alarm_name`, e.g. 96 97 ``` 98 $ terraform import aws_cloudwatch_metric_alarm.test alarm-12345 99 ```