github.com/atsaki/terraform@v0.4.3-0.20150919165407-25bba5967654/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 alarm_description = "This metric monitor ec2 cpu utilization" 49 alarm_actions = ["${aws_autoscaling_policy.bat.arn}"] 50 } 51 ``` 52 ## Argument Reference 53 54 See [related part of AWS Docs](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html) 55 for details about valid values. 56 57 The following arguments are supported: 58 59 * `alarm_name` - (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account 60 * `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`. 61 * `evaluation_periods` - (Required) The number of periods over which data is compared to the specified threshold. 62 * `metric_name` - (Required) The name for the alarm's associated metric. 63 See docs for [supported metrics](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html). 64 * `namespace` - (Required) The namespace for the alarm's associated metric. 65 * `period` - (Required) The period in seconds over which the specified `statistic` is applied. 66 * `statistic` - (Required) The statistic to apply to the alarm's associated metric. 67 Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` 68 * `threshold` - (Required) The value against which the specified statistic is compared. 69 * `actions_enabled` - (Optional) Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to `true`. 70 * `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). 71 * `alarm_description` - (Optional) The description for the alarm. 72 * `dimensions` - (Optional) The dimensions for the alarm's associated metric. 73 * `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). 74 * `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). 75 * `unit` - (Optional) The unit for the alarm's associated metric.