-
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
resource/aws_cloudwatch_metric_alarm: Add period
to metric_query
block
#29896
Conversation
Community NoteVoting for Prioritization
For Submitters
|
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.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccCloudWatchMetricAlarm_' PKG=cloudwatch ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudwatch/... -v -count 1 -parallel 3 -run=TestAccCloudWatchMetricAlarm_ -timeout 180m
=== RUN TestAccCloudWatchMetricAlarm_basic
=== PAUSE TestAccCloudWatchMetricAlarm_basic
=== RUN TestAccCloudWatchMetricAlarm_AlarmActions_ec2Automate
=== PAUSE TestAccCloudWatchMetricAlarm_AlarmActions_ec2Automate
=== RUN TestAccCloudWatchMetricAlarm_AlarmActions_snsTopic
=== PAUSE TestAccCloudWatchMetricAlarm_AlarmActions_snsTopic
=== RUN TestAccCloudWatchMetricAlarm_AlarmActions_swfAction
=== PAUSE TestAccCloudWatchMetricAlarm_AlarmActions_swfAction
=== RUN TestAccCloudWatchMetricAlarm_dataPointsToAlarm
=== PAUSE TestAccCloudWatchMetricAlarm_dataPointsToAlarm
=== RUN TestAccCloudWatchMetricAlarm_treatMissingData
=== PAUSE TestAccCloudWatchMetricAlarm_treatMissingData
=== RUN TestAccCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== PAUSE TestAccCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== RUN TestAccCloudWatchMetricAlarm_extendedStatistic
=== PAUSE TestAccCloudWatchMetricAlarm_extendedStatistic
=== RUN TestAccCloudWatchMetricAlarm_metricQuery
=== PAUSE TestAccCloudWatchMetricAlarm_metricQuery
=== RUN TestAccCloudWatchMetricAlarm_missingStatistic
=== PAUSE TestAccCloudWatchMetricAlarm_missingStatistic
=== RUN TestAccCloudWatchMetricAlarm_tags
=== PAUSE TestAccCloudWatchMetricAlarm_tags
=== RUN TestAccCloudWatchMetricAlarm_disappears
=== PAUSE TestAccCloudWatchMetricAlarm_disappears
=== CONT TestAccCloudWatchMetricAlarm_basic
=== CONT TestAccCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== CONT TestAccCloudWatchMetricAlarm_missingStatistic
--- PASS: TestAccCloudWatchMetricAlarm_missingStatistic (6.75s)
=== CONT TestAccCloudWatchMetricAlarm_extendedStatistic
--- PASS: TestAccCloudWatchMetricAlarm_basic (19.75s)
=== CONT TestAccCloudWatchMetricAlarm_AlarmActions_swfAction
--- PASS: TestAccCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (29.34s)
=== CONT TestAccCloudWatchMetricAlarm_treatMissingData
--- PASS: TestAccCloudWatchMetricAlarm_AlarmActions_swfAction (18.73s)
=== CONT TestAccCloudWatchMetricAlarm_dataPointsToAlarm
--- PASS: TestAccCloudWatchMetricAlarm_dataPointsToAlarm (14.79s)
=== CONT TestAccCloudWatchMetricAlarm_disappears
--- PASS: TestAccCloudWatchMetricAlarm_disappears (14.19s)
=== CONT TestAccCloudWatchMetricAlarm_metricQuery
--- PASS: TestAccCloudWatchMetricAlarm_treatMissingData (44.17s)
=== CONT TestAccCloudWatchMetricAlarm_AlarmActions_snsTopic
--- PASS: TestAccCloudWatchMetricAlarm_AlarmActions_snsTopic (18.98s)
=== CONT TestAccCloudWatchMetricAlarm_AlarmActions_ec2Automate
--- PASS: TestAccCloudWatchMetricAlarm_metricQuery (92.89s)
=== CONT TestAccCloudWatchMetricAlarm_tags
--- PASS: TestAccCloudWatchMetricAlarm_extendedStatistic (181.75s)
--- PASS: TestAccCloudWatchMetricAlarm_tags (38.07s)
--- PASS: TestAccCloudWatchMetricAlarm_AlarmActions_ec2Automate (230.41s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/cloudwatch 328.163s
@@ -113,6 +113,10 @@ func ResourceMetricAlarm() *schema.Resource { | |||
"period": { | |||
Type: schema.TypeInt, | |||
Required: true, | |||
ValidateFunc: validation.Any( | |||
validation.IntInSlice([]int{1, 5, 10, 30}), |
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.
Documentation in https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html suggests
Valid values are 10, 30, and any multiple of 60.
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.
Hi @henkka,the following line
validation.IntDivisibleBy(60)
covers the multiples of 60 case. It's good to have extra eyes review things, though 🙂
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.
Ah right, my point was that this should actually be validation.IntInSlice([]int{10, 30})
if we'd like to comply with what AWS allows currently
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.
Ah, I see what you're saying. The top-level period
, at
terraform-provider-aws/internal/service/cloudwatch/metric_alarm.go
Lines 170 to 178 in 9bccc30
"period": { | |
Type: schema.TypeInt, | |
Optional: true, | |
ConflictsWith: []string{"metric_query"}, | |
ValidateFunc: validation.Any( | |
validation.IntInSlice([]int{10, 30}), | |
validation.IntDivisibleBy(60), | |
), | |
}, |
10
, 30
, and multiples of 60
. The period
of a metric_query
, on the other hand, can be 1
, 5
, 10
, 30
, and multiples of 60
(https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDataQuery.html)
Hey, there! Does it have some estimation on when this will be released? Thanks! |
I also met troubles with this; my workaround is to create on the AWS console and import it to Terraform state, but I think it may raise this error again when I want to create or change other resources. |
This functionality has been released in v4.59.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Description
Adds missing
period
parameter tometric_query
block.Also adds validation to
metric_query.metric.period
.Relations
Closes #29398.
Closes #28617.
Closes #28547.
References
Output from Acceptance Testing