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

r/cloudwatch_metric_alarm - add validations #12817

Merged
merged 10 commits into from
Feb 18, 2021

Conversation

DrFaust92
Copy link
Collaborator

@DrFaust92 DrFaust92 commented Apr 14, 2020

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" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #13624
Relates #13826

Release note for CHANGELOG:

resource_aws_cloudwatch_metric_alarm: add plan time validations to `comparison_operator` and `statistic`, `metric_query.metric.unit`, `unit`.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm_'
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (14.22s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_disappears (32.10s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (36.33s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (38.08s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (43.27s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (49.03s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (50.49s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (70.35s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (76.07s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_tags (107.46s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (168.96s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (340.33s)

@DrFaust92 DrFaust92 requested a review from a team April 14, 2020 16:31
@ghost ghost added needs-triage Waiting for first response or review from a maintainer. size/S Managed by automation to categorize the size of a PR. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Apr 14, 2020
@ewbankkit
Copy link
Contributor

Verified acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSCloudWatchMetricAlarm_ -timeout 120m
=== 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
=== RUN   TestAccAWSCloudWatchMetricAlarm_tags
=== PAUSE TestAccAWSCloudWatchMetricAlarm_tags
=== RUN   TestAccAWSCloudWatchMetricAlarm_disappears
=== PAUSE TestAccAWSCloudWatchMetricAlarm_disappears
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate
=== CONT  TestAccAWSCloudWatchMetricAlarm_disappears
=== CONT  TestAccAWSCloudWatchMetricAlarm_tags
=== CONT  TestAccAWSCloudWatchMetricAlarm_missingStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_expression
=== CONT  TestAccAWSCloudWatchMetricAlarm_extendedStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== CONT  TestAccAWSCloudWatchMetricAlarm_treatMissingData
=== CONT  TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic
=== CONT  TestAccAWSCloudWatchMetricAlarm_basic
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (11.28s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_disappears (21.22s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (24.66s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (25.74s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (28.96s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (31.30s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (32.19s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (42.42s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (42.51s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_tags (63.80s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (101.23s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (228.22s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	228.265s

@DrFaust92 DrFaust92 force-pushed the r/cloudwatch_metric_alarm_refactor branch from 3c4c577 to 960f02d Compare May 19, 2020 16:32
@ewbankkit
Copy link
Contributor

Verified acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSCloudWatchMetricAlarm_ -timeout 120m
go: downloading github.com/aws/aws-sdk-go v1.31.0
go: extracting github.com/aws/aws-sdk-go v1.31.0
go: finding github.com/aws/aws-sdk-go v1.31.0
=== 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
=== RUN   TestAccAWSCloudWatchMetricAlarm_tags
=== PAUSE TestAccAWSCloudWatchMetricAlarm_tags
=== RUN   TestAccAWSCloudWatchMetricAlarm_disappears
=== PAUSE TestAccAWSCloudWatchMetricAlarm_disappears
=== CONT  TestAccAWSCloudWatchMetricAlarm_basic
=== CONT  TestAccAWSCloudWatchMetricAlarm_extendedStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_disappears
=== CONT  TestAccAWSCloudWatchMetricAlarm_tags
=== CONT  TestAccAWSCloudWatchMetricAlarm_missingStatistic
=== CONT  TestAccAWSCloudWatchMetricAlarm_expression
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction
=== CONT  TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
=== CONT  TestAccAWSCloudWatchMetricAlarm_treatMissingData
=== CONT  TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic
=== CONT  TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (10.93s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_disappears (21.02s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (23.25s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (24.78s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (27.06s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (29.07s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (30.23s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (40.76s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (40.92s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_tags (60.03s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (96.70s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (213.34s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	213.386s

@DrFaust92 DrFaust92 force-pushed the r/cloudwatch_metric_alarm_refactor branch from bc24a75 to 6cba084 Compare May 22, 2020 15:49
@DrFaust92 DrFaust92 added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 4, 2020
@DrFaust92 DrFaust92 force-pushed the r/cloudwatch_metric_alarm_refactor branch from 6cba084 to fe2feec Compare September 4, 2020 10:58
Base automatically changed from master to main January 23, 2021 00:57
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:57
@DrFaust92 DrFaust92 force-pushed the r/cloudwatch_metric_alarm_refactor branch from 0578850 to 469c142 Compare February 11, 2021 18:17
@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Feb 11, 2021
.changelog/12817.txt Outdated Show resolved Hide resolved
Co-authored-by: Brian Flad <bflad417@gmail.com>
@bflad bflad self-assigned this Feb 18, 2021
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.

Fixing up a few things before verifying again. 👍

aws/resource_aws_cloudwatch_metric_alarm.go Outdated Show resolved Hide resolved
aws/resource_aws_cloudwatch_metric_alarm.go Outdated Show resolved Hide resolved
},
"period": {
Type: schema.TypeInt,
Optional: true,
ConflictsWith: []string{"metric_query"},
ValidateFunc: validation.Any(
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is valid 👍

aws/resource_aws_cloudwatch_metric_alarm.go Outdated Show resolved Hide resolved
aws/resource_aws_cloudwatch_metric_alarm.go Outdated Show resolved Hide resolved
aws/resource_aws_cloudwatch_metric_alarm.go Outdated Show resolved Hide resolved
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.

Looks good to me, thank you, @DrFaust92 🚀

References:

Output from acceptance testing in AWS Commercial:

--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (177.84s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (26.40s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (25.53s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (25.28s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (22.65s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_disappears (19.51s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (33.19s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (67.61s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (22.59s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (11.62s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_tags (47.01s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (33.18s)

Output from acceptance testing in AWS GovCloud (US):

--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate (199.57s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SNSTopic (23.82s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_AlarmActions_SWFAction (23.14s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (22.45s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (19.66s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_disappears (16.42s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (33.05s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_expression (78.23s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (18.22s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (8.10s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_tags (48.94s)
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (33.07s)

@bflad bflad merged commit bf4f55c into hashicorp:main Feb 18, 2021
@github-actions github-actions bot added this to the v3.29.0 milestone Feb 18, 2021
@ghost
Copy link

ghost commented Feb 19, 2021

This has been released in version 3.29.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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 21, 2021

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 as resolved and limited conversation to collaborators Mar 21, 2021
@DrFaust92 DrFaust92 deleted the r/cloudwatch_metric_alarm_refactor branch April 15, 2021 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. size/L 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.

3 participants