title: CWAgent Metric alarms created using Terraform doesn't get data points collected (stays in Insufficient data)
body: <p>I have created a CloudWatch alarm for memory utilization using Terraform but the alarm doesn't move to <code>OK</code> state (stays in <code>INSUFFICIENT_DATA</code>). But when I created the same alarm with same exact configuration manually from the AWS management console it moved to the <code>OK</code> state and I see the data point.</p>
  
  <p>I have installed CloudWatch Agent successfully in the EC2 instance that I'm trying to create alarms and I can see the metrics in the CloudWatch Metrics section.</p>
  
  <p>My Terraform code:</p>
  
  <pre><code>resource "aws_cloudwatch_metric_alarm" "memory" {
    alarm_name = "memory-utilization-alarm-${var.env}"
    comparison_operator = "GreaterThanOrEqualToThreshold"
    evaluation_periods  = "1"
    metric_name = "mem_used_percent"
    namespace = "CWAgent"
    period = "300"
    statistic = "Average"
    threshold = "${var.alarms_memory_threshold}"
    alarm_description = "This metric monitors ec2 memory utilization"
    alarm_actions = [ "${aws_sns_topic.sns_topic.arn}" ]
  
    dimensions = {
      InstanceId = "${var.instance_id}"
      ImageId = "${var.ami_id}"
    }
  
    tags = {
      Environment = "${var.env}"
      Project = "${var.project}"
      Provisioner="cloudwatch"
      Name = "${local.name}.memory"
    }
  }
  </code></pre>
  
  <p>AWS CLI output from describing alarm created using Terraform:</p>
  
  <pre><code>aws cloudwatch describe-alarms --alarm-names memory-utilization-alarm-dev
  {
      "MetricAlarms": [
          {
              "EvaluationPeriods": 1, 
              "TreatMissingData": "missing", 
              "AlarmArn": "arn:aws:cloudwatch:us-west-2:289914521333:alarm:memory-utilization-alarm-dev", 
              "StateUpdatedTimestamp": "2019-07-12T08:45:07.020Z", 
              "AlarmConfigurationUpdatedTimestamp": "2019-07-12T08:45:07.020Z", 
              "ComparisonOperator": "GreaterThanOrEqualToThreshold", 
              "AlarmActions": [
                  "arn:aws:sns:us-west-2:289914521333:sns-topic"
              ], 
              "AlarmDescription": "This metric monitors ec2 memory utilization", 
              "Namespace": "CWAgent", 
              "Period": 300, 
              "StateValue": "INSUFFICIENT_DATA", 
              "Threshold": 80.0, 
              "AlarmName": "memory-utilization-alarm-dev", 
              "Dimensions": [
                  {
                      "Name": "InstanceId", 
                      "Value": "i-03417f2d90d3dc6ca"
                  }, 
                  {
                      "Name": "ImageId", 
                      "Value": "ami-09d1383e2a5ae8a93"
                  }
              ], 
              "Statistic": "Average", 
              "StateReason": "Unchecked: Initial alarm creation", 
              "InsufficientDataActions": [], 
              "OKActions": [], 
              "ActionsEnabled": true, 
              "MetricName": "mem_used_percent"
          }
      ]
  }
  
  </code></pre>
  
  <p>AWS CLI output from describing alarm created using the AWS console:</p>
  
  <pre><code>aws cloudwatch describe-alarms --alarm-names memory-utilization-alarm
  {
      "MetricAlarms": [
          {
              "Dimensions": [
                  {
                      "Name": "InstanceId", 
                      "Value": "i-03417f2d90d3dc6ca"
                  }, 
                  {
                      "Name": "ImageId", 
                      "Value": "ami-09d1383e2a5ae8a93"
                  }, 
                  {
                      "Name": "InstanceType", 
                      "Value": "t3.large"
                  }
              ], 
              "Namespace": "CWAgent", 
              "DatapointsToAlarm": 1, 
              "ActionsEnabled": true, 
              "MetricName": "mem_used_percent", 
              "EvaluationPeriods": 1, 
              "StateValue": "OK", 
              "StateUpdatedTimestamp": "2019-07-12T09:49:28.749Z", 
              "AlarmConfigurationUpdatedTimestamp": "2019-07-12T09:47:55.914Z", 
              "AlarmActions": [
                  "arn:aws:sns:us-west-2:289914521333:sns-topic"
              ], 
              "InsufficientDataActions": [], 
              "AlarmArn": "arn:aws:cloudwatch:us-west-2:289914521333:alarm:memory-utilization-alarm", 
              "StateReasonData": "{\"version\":\"1.0\",\"queryDate\":\"2019-07-12T09:49:28.746+0000\",\"startDate\":\"2019-07-12T09:44:00.000+0000\",\"statistic\":\"Average\",\"period\":300,\"recentDatapoints\":[61.253520518958474],\"threshold\":80.0}", 
              "Threshold": 80.0, 
              "StateReason": "Threshold Crossed: 1 out of the last 1 datapoints [61.253520518958474 (12/07/19 09:44:00)] was not greater than or equal to the threshold (80.0) (minimum 1 datapoint for ALARM -&gt; OK transition).", 
              "OKActions": [], 
              "AlarmDescription": "memory-utilization-alarm", 
              "Period": 300, 
              "ComparisonOperator": "GreaterThanOrEqualToThreshold", 
              "AlarmName": "memory-utilization-alarm", 
              "Statistic": "Average", 
              "TreatMissingData": "missing"
          }
      ]
  }
  </code></pre>