Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm #8085

Merged

Conversation

sjauld
Copy link
Contributor

@sjauld sjauld commented Mar 26, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #7593

Changes proposed in this pull request:

  • allow updates to metric_query on aws_cloudwatch_metric_alarm

Output from acceptance testing:

aws-vault exec sand-superuser -- make testacc TESTARGS="-run TestAccAWSCloudWatchMetricAlarm"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run TestAccAWSCloudWatchMetricAlarm -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSCloudWatchMetricAlarm_basic
=== PAUSE TestAccAWSCloudWatchMetricAlarm_basic
=== RUN   TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate
=== PAUSE TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate
=== RUN   TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic
=== PAUSE TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic
=== RUN   TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction
=== PAUSE TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction
=== RUN   TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
=== PAUSE TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
=== RUN   TestAccAWSCloudWatchMetricAlarm_treatMissingData
=== PAUSE TestAccAWSCloudWatchMetricAlarm_treatMissingData
=== RUN   TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== PAUSE TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== RUN   TestAccAWSCloudWatchMetricAlarm_extendedStatistic
=== PAUSE TestAccAWSCloudWatchMetricAlarm_extendedStatistic
=== RUN   TestAccAWSCloudWatchMetricAlarm_expression
=== PAUSE TestAccAWSCloudWatchMetricAlarm_expression
=== RUN   TestAccAWSCloudWatchMetricAlarm_missingStatistic
=== PAUSE TestAccAWSCloudWatchMetricAlarm_missingStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_basic
=== CONT  TestAccAWSCloudWatchMetricAlarm_treatMissingData
=== CONT  TestAccAWSCloudWatchMetricAlarm_missingStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic
=== CONT  TestAccAWSCloudWatchMetricAlarm_extendedStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction
=== CONT  TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate
=== CONT  TestAccAWSCloudWatchMetricAlarm_expression
=== CONT  TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (10.63s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (33.01s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (33.07s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (37.68s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (41.93s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (42.46s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (55.71s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (56.70s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (113.50s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (360.05s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       360.108s

Please see ad064a6 for the output of the failing test prior to this patch.

-- Test output below --

aws-vault exec sand-superuser -- make testacc TESTARGS="-run TestAccAWSCloudWatchMetricAlarm_expression"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run TestAccAWSCloudWatchMetricAlarm_expression -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSCloudWatchMetricAlarm_expression
=== PAUSE TestAccAWSCloudWatchMetricAlarm_expression
=== CONT  TestAccAWSCloudWatchMetricAlarm_expression
2019/03/27 09:00:55 [WARN] Test: Step plan: DIFF:

CREATE: aws_cloudwatch_metric_alarm.foobar
  actions_enabled:                                        "" => "true"
  alarm_description:                                      "" => "This metric monitors ec2 cpu utilization"
  alarm_name:                                             "" => "terraform-test-foobar6453812907472873677" (forces new resource)
  arn:                                                    "" => "<computed>"
  comparison_operator:                                    "" => "GreaterThanOrEqualToThreshold"
  evaluate_low_sample_count_percentiles:                  "" => "<computed>"
  evaluation_periods:                                     "" => "2"
  metric_query.#:                                         "" => "1"
  metric_query.2835246568.expression:                     "" => "m1"
  metric_query.2835246568.id:                             "" => "e1"
  metric_query.2835246568.label:                          "" => "cat"
  metric_query.2835246568.metric.#:                       "" => "1"
  metric_query.2835246568.metric.0.dimensions.%:          "" => "1"
  metric_query.2835246568.metric.0.dimensions.InstanceId: "" => "i-abc123"
  metric_query.2835246568.metric.0.metric_name:           "" => "CPUUtilization"
  metric_query.2835246568.metric.0.namespace:             "" => "AWS/EC2"
  metric_query.2835246568.metric.0.period:                "" => "120"
  metric_query.2835246568.metric.0.stat:                  "" => "Average"
  metric_query.2835246568.metric.0.unit:                  "" => "Count"
  metric_query.2835246568.return_data:                    "" => "false"
  threshold:                                              "" => "80"
  treat_missing_data:                                     "" => "missing"

STATE:

<no state>
2019/03/27 09:00:58 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error occurred:
        * aws_cloudwatch_metric_alarm.foobar: No metric_query may have both `expression` and a `metric` specified

2019/03/27 09:00:58 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error occurred:
        * aws_cloudwatch_metric_alarm.foobar: No metric_query may have both `expression` and a `metric` specified

2019/03/27 09:01:02 [WARN] Test: Step plan: DIFF:

CREATE: aws_cloudwatch_metric_alarm.foobar
  actions_enabled:                                        "" => "true"
  alarm_description:                                      "" => "This metric monitors ec2 cpu utilization"
  alarm_name:                                             "" => "terraform-test-foobar6453812907472873677" (forces new resource)
  arn:                                                    "" => "<computed>"
  comparison_operator:                                    "" => "GreaterThanOrEqualToThreshold"
  evaluate_low_sample_count_percentiles:                  "" => "<computed>"
  evaluation_periods:                                     "" => "2"
  metric_query.#:                                         "" => "2"
  metric_query.2520032513.expression:                     "" => ""
  metric_query.2520032513.id:                             "" => "m1"
  metric_query.2520032513.label:                          "" => ""
  metric_query.2520032513.metric.#:                       "" => "1"
  metric_query.2520032513.metric.0.dimensions.%:          "" => "1"
  metric_query.2520032513.metric.0.dimensions.InstanceId: "" => "i-abc123"
  metric_query.2520032513.metric.0.metric_name:           "" => "CPUUtilization"
  metric_query.2520032513.metric.0.namespace:             "" => "AWS/EC2"
  metric_query.2520032513.metric.0.period:                "" => "120"
  metric_query.2520032513.metric.0.stat:                  "" => "Average"
  metric_query.2520032513.metric.0.unit:                  "" => "Count"
  metric_query.2520032513.return_data:                    "" => "false"
  metric_query.3055748110.expression:                     "" => "m1"
  metric_query.3055748110.id:                             "" => "e1"
  metric_query.3055748110.label:                          "" => "cat"
  metric_query.3055748110.metric.#:                       "" => "0"
  metric_query.3055748110.return_data:                    "" => "true"
  threshold:                                              "" => "80"
  treat_missing_data:                                     "" => "missing"

STATE:

<no state>
2019/03/27 09:01:26 [WARN] Test: Step plan: DIFF:

UPDATE: aws_cloudwatch_metric_alarm.foobar
  metric_query.#:                                         "2" => "3"
  metric_query.2520032513.expression:                     "" => ""
  metric_query.2520032513.id:                             "m1" => "m1"
  metric_query.2520032513.label:                          "" => ""
  metric_query.2520032513.metric.#:                       "1" => "1"
  metric_query.2520032513.metric.0.dimensions.InstanceId: "i-abc123" => "i-abc123"
  metric_query.2520032513.metric.0.metric_name:           "CPUUtilization" => "CPUUtilization"
  metric_query.2520032513.metric.0.namespace:             "AWS/EC2" => "AWS/EC2"
  metric_query.2520032513.metric.0.period:                "120" => "120"
  metric_query.2520032513.metric.0.stat:                  "Average" => "Average"
  metric_query.2520032513.metric.0.unit:                  "Count" => "Count"
  metric_query.2520032513.return_data:                    "false" => "false"
  metric_query.2939696463.expression:                     "" => "m1"
  metric_query.2939696463.id:                             "" => "e1"
  metric_query.2939696463.label:                          "" => "cat"
  metric_query.2939696463.metric.#:                       "0" => "0"
  metric_query.2939696463.return_data:                    "" => "false"
  metric_query.3055748110.expression:                     "m1" => ""
  metric_query.3055748110.id:                             "e1" => ""
  metric_query.3055748110.label:                          "cat" => ""
  metric_query.3055748110.metric.#:                       "0" => "0"
  metric_query.3055748110.return_data:                    "true" => "false"
  metric_query.3779742054.expression:                     "" => "e1"
  metric_query.3779742054.id:                             "" => "e2"
  metric_query.3779742054.label:                          "" => "bug"
  metric_query.3779742054.metric.#:                       "0" => "0"
  metric_query.3779742054.return_data:                    "" => "true"

STATE:

aws_cloudwatch_metric_alarm.foobar:
  ID = terraform-test-foobar6453812907472873677
  provider = provider.aws
  actions_enabled = true
  alarm_actions.# = 0
  alarm_description = This metric monitors ec2 cpu utilization
  alarm_name = terraform-test-foobar6453812907472873677
  arn = arn:aws:cloudwatch:us-west-2:130475909466:alarm:terraform-test-foobar6453812907472873677
  comparison_operator = GreaterThanOrEqualToThreshold
  datapoints_to_alarm = 0
  dimensions.% = 0
  evaluate_low_sample_count_percentiles =
  evaluation_periods = 2
  extended_statistic =
  insufficient_data_actions.# = 0
  metric_name =
  metric_query.# = 2
  metric_query.2520032513.expression =
  metric_query.2520032513.id = m1
  metric_query.2520032513.label =
  metric_query.2520032513.metric.# = 1
  metric_query.2520032513.metric.0.dimensions.% = 1
  metric_query.2520032513.metric.0.dimensions.InstanceId = i-abc123
  metric_query.2520032513.metric.0.metric_name = CPUUtilization
  metric_query.2520032513.metric.0.namespace = AWS/EC2
  metric_query.2520032513.metric.0.period = 120
  metric_query.2520032513.metric.0.stat = Average
  metric_query.2520032513.metric.0.unit = Count
  metric_query.2520032513.return_data = false
  metric_query.3055748110.expression = m1
  metric_query.3055748110.id = e1
  metric_query.3055748110.label = cat
  metric_query.3055748110.metric.# = 0
  metric_query.3055748110.return_data = true
  namespace =
  ok_actions.# = 0
  period = 0
  statistic =
  threshold = 80
  treat_missing_data = missing
  unit =
2019/03/27 09:01:50 [WARN] Test: Step plan: DIFF:

UPDATE: aws_cloudwatch_metric_alarm.foobar
  metric_query.#:                                         "3" => "2"
  metric_query.2520032513.expression:                     "" => ""
  metric_query.2520032513.id:                             "m1" => "m1"
  metric_query.2520032513.label:                          "" => ""
  metric_query.2520032513.metric.#:                       "1" => "1"
  metric_query.2520032513.metric.0.dimensions.InstanceId: "i-abc123" => "i-abc123"
  metric_query.2520032513.metric.0.metric_name:           "CPUUtilization" => "CPUUtilization"
  metric_query.2520032513.metric.0.namespace:             "AWS/EC2" => "AWS/EC2"
  metric_query.2520032513.metric.0.period:                "120" => "120"
  metric_query.2520032513.metric.0.stat:                  "Average" => "Average"
  metric_query.2520032513.metric.0.unit:                  "Count" => "Count"
  metric_query.2520032513.return_data:                    "false" => "false"
  metric_query.2939696463.expression:                     "m1" => ""
  metric_query.2939696463.id:                             "e1" => ""
  metric_query.2939696463.label:                          "cat" => ""
  metric_query.2939696463.metric.#:                       "0" => "0"
  metric_query.2939696463.return_data:                    "false" => "false"
  metric_query.3055748110.expression:                     "" => "m1"
  metric_query.3055748110.id:                             "" => "e1"
  metric_query.3055748110.label:                          "" => "cat"
  metric_query.3055748110.metric.#:                       "0" => "0"
  metric_query.3055748110.return_data:                    "" => "true"
  metric_query.3779742054.expression:                     "e1" => ""
  metric_query.3779742054.id:                             "e2" => ""
  metric_query.3779742054.label:                          "bug" => ""
  metric_query.3779742054.metric.#:                       "0" => "0"
  metric_query.3779742054.return_data:                    "true" => "false"

STATE:

aws_cloudwatch_metric_alarm.foobar:
  ID = terraform-test-foobar6453812907472873677
  provider = provider.aws
  actions_enabled = true
  alarm_actions.# = 0
  alarm_description = This metric monitors ec2 cpu utilization
  alarm_name = terraform-test-foobar6453812907472873677
  arn = arn:aws:cloudwatch:us-west-2:130475909466:alarm:terraform-test-foobar6453812907472873677
  comparison_operator = GreaterThanOrEqualToThreshold
  datapoints_to_alarm = 0
  dimensions.% = 0
  evaluate_low_sample_count_percentiles =
  evaluation_periods = 2
  extended_statistic =
  insufficient_data_actions.# = 0
  metric_name =
  metric_query.# = 3
  metric_query.2520032513.expression =
  metric_query.2520032513.id = m1
  metric_query.2520032513.label =
  metric_query.2520032513.metric.# = 1
  metric_query.2520032513.metric.0.dimensions.% = 1
  metric_query.2520032513.metric.0.dimensions.InstanceId = i-abc123
  metric_query.2520032513.metric.0.metric_name = CPUUtilization
  metric_query.2520032513.metric.0.namespace = AWS/EC2
  metric_query.2520032513.metric.0.period = 120
  metric_query.2520032513.metric.0.stat = Average
  metric_query.2520032513.metric.0.unit = Count
  metric_query.2520032513.return_data = false
  metric_query.2939696463.expression = m1
  metric_query.2939696463.id = e1
  metric_query.2939696463.label = cat
  metric_query.2939696463.metric.# = 0
  metric_query.2939696463.return_data = false
  metric_query.3779742054.expression = e1
  metric_query.3779742054.id = e2
  metric_query.3779742054.label = bug
  metric_query.3779742054.metric.# = 0
  metric_query.3779742054.return_data = true
  namespace =
  ok_actions.# = 0
  period = 0
  statistic =
  threshold = 80
  treat_missing_data = missing
  unit =
2019/03/27 09:02:16 [WARN] Test: Step plan: DIFF:

UPDATE: aws_cloudwatch_metric_alarm.foobar
  metric_query.156515512.expression:                      "" => ""
  metric_query.156515512.id:                              "" => "m1"
  metric_query.156515512.label:                           "" => ""
  metric_query.156515512.metric.#:                        "0" => "1"
  metric_query.156515512.metric.0.dimensions.%:           "0" => "1"
  metric_query.156515512.metric.0.dimensions.InstanceId:  "" => "i-abc123"
  metric_query.156515512.metric.0.metric_name:            "" => "CPUUtilization"
  metric_query.156515512.metric.0.namespace:              "" => "AWS/EC2"
  metric_query.156515512.metric.0.period:                 "" => "120"
  metric_query.156515512.metric.0.stat:                   "" => "Maximum"
  metric_query.156515512.metric.0.unit:                   "" => "Count"
  metric_query.156515512.return_data:                     "" => "false"
  metric_query.2520032513.expression:                     "" => ""
  metric_query.2520032513.id:                             "m1" => ""
  metric_query.2520032513.label:                          "" => ""
  metric_query.2520032513.metric.#:                       "1" => "0"
  metric_query.2520032513.metric.0.dimensions.%:          "1" => "0"
  metric_query.2520032513.metric.0.dimensions.InstanceId: "i-abc123" => ""
  metric_query.2520032513.metric.0.metric_name:           "CPUUtilization" => ""
  metric_query.2520032513.metric.0.namespace:             "AWS/EC2" => ""
  metric_query.2520032513.metric.0.period:                "120" => "0"
  metric_query.2520032513.metric.0.stat:                  "Average" => ""
  metric_query.2520032513.metric.0.unit:                  "Count" => ""
  metric_query.2520032513.return_data:                    "false" => "false"
  metric_query.3055748110.expression:                     "m1" => "m1"
  metric_query.3055748110.id:                             "e1" => "e1"
  metric_query.3055748110.label:                          "cat" => "cat"
  metric_query.3055748110.metric.#:                       "0" => "0"
  metric_query.3055748110.return_data:                    "true" => "true"

STATE:

aws_cloudwatch_metric_alarm.foobar:
  ID = terraform-test-foobar6453812907472873677
  provider = provider.aws
  actions_enabled = true
  alarm_actions.# = 0
  alarm_description = This metric monitors ec2 cpu utilization
  alarm_name = terraform-test-foobar6453812907472873677
  arn = arn:aws:cloudwatch:us-west-2:130475909466:alarm:terraform-test-foobar6453812907472873677
  comparison_operator = GreaterThanOrEqualToThreshold
  datapoints_to_alarm = 0
  dimensions.% = 0
  evaluate_low_sample_count_percentiles =
  evaluation_periods = 2
  extended_statistic =
  insufficient_data_actions.# = 0
  metric_name =
  metric_query.# = 2
  metric_query.2520032513.expression =
  metric_query.2520032513.id = m1
  metric_query.2520032513.label =
  metric_query.2520032513.metric.# = 1
  metric_query.2520032513.metric.0.dimensions.% = 1
  metric_query.2520032513.metric.0.dimensions.InstanceId = i-abc123
  metric_query.2520032513.metric.0.metric_name = CPUUtilization
  metric_query.2520032513.metric.0.namespace = AWS/EC2
  metric_query.2520032513.metric.0.period = 120
  metric_query.2520032513.metric.0.stat = Average
  metric_query.2520032513.metric.0.unit = Count
  metric_query.2520032513.return_data = false
  metric_query.3055748110.expression = m1
  metric_query.3055748110.id = e1
  metric_query.3055748110.label = cat
  metric_query.3055748110.metric.# = 0
  metric_query.3055748110.return_data = true
  namespace =
  ok_actions.# = 0
  period = 0
  statistic =
  threshold = 80
  treat_missing_data = missing
  unit =
2019/03/27 09:02:19 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error occurred:
        * aws_cloudwatch_metric_alarm.foobar: Updating metric alarm failed: InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, PutMetricAlarmInput.Metrics[2].Id.

2019/03/27 09:02:19 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error occurred:
        * aws_cloudwatch_metric_alarm.foobar: Updating metric alarm failed: InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, PutMetricAlarmInput.Metrics[2].Id.

2019/03/27 09:02:19 [WARN] Test: Executing destroy step
2019/03/27 09:02:24 [WARN] Test: Step plan: DIFF:

DESTROY: aws_cloudwatch_metric_alarm.foobar

STATE:

aws_cloudwatch_metric_alarm.foobar:
  ID = terraform-test-foobar6453812907472873677
  provider = provider.aws
  actions_enabled = true
  alarm_actions.# = 0
  alarm_description = This metric monitors ec2 cpu utilization
  alarm_name = terraform-test-foobar6453812907472873677
  arn = arn:aws:cloudwatch:us-west-2:130475909466:alarm:terraform-test-foobar6453812907472873677
  comparison_operator = GreaterThanOrEqualToThreshold
  datapoints_to_alarm = 0
  dimensions.% = 0
  evaluate_low_sample_count_percentiles =
  evaluation_periods = 2
  extended_statistic =
  insufficient_data_actions.# = 0
  metric_name =
  metric_query.# = 2
  metric_query.2520032513.expression =
  metric_query.2520032513.id = m1
  metric_query.2520032513.label =
  metric_query.2520032513.metric.# = 1
  metric_query.2520032513.metric.0.dimensions.% = 1
  metric_query.2520032513.metric.0.dimensions.InstanceId = i-abc123
  metric_query.2520032513.metric.0.metric_name = CPUUtilization
  metric_query.2520032513.metric.0.namespace = AWS/EC2
  metric_query.2520032513.metric.0.period = 120
  metric_query.2520032513.metric.0.stat = Average
  metric_query.2520032513.metric.0.unit = Count
  metric_query.2520032513.return_data = false
  metric_query.3055748110.expression = m1
  metric_query.3055748110.id = e1
  metric_query.3055748110.label = cat
  metric_query.3055748110.metric.# = 0
  metric_query.3055748110.return_data = true
  namespace =
  ok_actions.# = 0
  period = 0
  statistic =
  threshold = 80
  treat_missing_data = missing
  unit =
--- FAIL: TestAccAWSCloudWatchMetricAlarm_expression (104.76s)
    testing.go:538: Step 4 error: Error applying: 1 error occurred:
                * aws_cloudwatch_metric_alarm.foobar: 1 error occurred:
                * aws_cloudwatch_metric_alarm.foobar: Updating metric alarm failed: InvalidParameter: 1 validation error(s) found.
        - minimum field size of 1, PutMetricAlarmInput.Metrics[2].Id.

FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       105.334s
make: *** [testacc] Error 1
@ghost ghost added size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Mar 26, 2019
@sjauld sjauld changed the title [WIP] Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm (#7593) [WIP] Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm Mar 26, 2019
@sjauld sjauld changed the title [WIP] Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm Mar 26, 2019
@bflad bflad added service/cloudwatch Issues and PRs that pertain to the cloudwatch service. bug Addresses a defect in current functionality. labels Mar 28, 2019
@bflad bflad added this to the v2.4.0 milestone Mar 28, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the fix and testing update, @sjauld! I can confirm the test change adequately covers the problem mentioned in the issue. 🚀

Prior to code change:

--- FAIL: TestAccAWSCloudWatchMetricAlarm_expression (30.16s)
    testing.go:538: Step 4 error: Error applying: 1 error occurred:
        	* aws_cloudwatch_metric_alarm.foobar: 1 error occurred:
        	* aws_cloudwatch_metric_alarm.foobar: Updating metric alarm failed: InvalidParameter: 1 validation error(s) found.
        - minimum field size of 1, PutMetricAlarmInput.Metrics[2].Id.

Output from acceptance testing:

--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (4.92s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (11.65s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (11.74s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (12.72s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (13.57s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (15.23s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (17.74s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (18.06s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (34.04s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (173.47s)

@bflad bflad merged commit ecffa36 into hashicorp:master Mar 28, 2019
bflad added a commit that referenced this pull request Mar 28, 2019
@bflad
Copy link
Contributor

bflad commented Mar 29, 2019

This has been released in version 2.4.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updates to metric_query on aws_cloudwatch_metric_alarm fail if dimensions is set
2 participants