-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Updates to metric_query on aws_cloudwatch_metric_alarm fail if dimensions is set #7593
Comments
Having looked at the state, it seems that the update operation creates a 4th empty metric with no ID:
this leaves terraform in an unrecoverable state until the resource is destroyed |
I can confirm that the address of |
I confirm the issue |
-- 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
The fix for this has been merged and will release with version 2.4.0 of the Terraform AWS Provider, likely later today. |
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 can replicate the error by:
|
This was fixed in 2.4 as per the above. Please try upgrading!
…On Fri, 14 Jun 2019 at 07:59, Islam Azab ***@***.***> wrote:
I can replicate the error by:
- creating a relative metric
- then trying to update it
Updating metric alarm failed: InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, PutMetricAlarmInput.Metrics[2].Id.
$ terraform -v
Terraform v0.11.13
+ provider.aws v1.60.0
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7593>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB6Z4NYSRQCVZJXBNN6Z6PDP2K7NRANCNFSM4GYFSCPA>
.
|
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
Terraform Version
To reproduce the error, make any change to the dimension metric queries, for example change
metric_name
onm1
to4XXError
.Expected Behavior
The metric query is updates as expected to alert on percentage of 4XXs
Actual Behavior
Apply fails with:
Steps to Reproduce
terraform apply
the HCL abovemetric_name
on line 22 to4XXError
terraform apply
againImportant Factoids
This only seems to affect metrics with
dimensions
.The text was updated successfully, but these errors were encountered: