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