-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Bugfix: allow updates to metric_query on aws_cloudwatch_metric_alarm #8085
Conversation
-- 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
There was a problem hiding this 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)
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. |
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! |
Community Note
Fixes #7593
Changes proposed in this pull request:
Output from acceptance testing:
Please see ad064a6 for the output of the failing test prior to this patch.