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/aws_cloudwatch_metric_alarm: Support optional datapoints_to_alarm configuration #2609

Merged
merged 4 commits into from
Jan 3, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 9, 2017

Prerequisite #2608
Closes #2607

 make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudWatchMetricAlarm -timeout 120m
=== RUN   TestAccAWSCloudWatchMetricAlarm_importBasic
--- PASS: TestAccAWSCloudWatchMetricAlarm_importBasic (11.76s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_basic
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (9.71s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (11.28s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_treatMissingData
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (16.26s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (18.76s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_extendedStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (10.03s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_missingStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (3.24s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	81.076s

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 9, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

Hi @bflad

This is looking very good! :)

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm_'              

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudWatchMetricAlarm_ -timeout 120m
=== RUN   TestAccAWSCloudWatchMetricAlarm_importBasic
--- PASS: TestAccAWSCloudWatchMetricAlarm_importBasic (24.11s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_basic
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (21.92s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (21.49s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_treatMissingData
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (36.71s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (37.45s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_extendedStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (21.59s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_missingStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (5.75s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	169.084s

Just left a few nitpicks. Thanks!

@@ -81,6 +81,7 @@ The following arguments are supported:
* `actions_enabled` - (Optional) Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to `true`.
* `alarm_actions` - (Optional) The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Number (ARN).
* `alarm_description` - (Optional) The description for the alarm.
* `datapoints_to_alarm` - (Optional) The number of datapoints that must be breaching to trigger the alarm..
Copy link
Contributor

Choose a reason for hiding this comment

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

Additional dot at the end

evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "120"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix the spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oi! I have since turned on whitespace character visibility to prevent this in the future. 😄

func testAccAWSCloudWatchMetricAlarmConfigDatapointsToAlarm(rName string) string {
return fmt.Sprintf(`
resource "aws_cloudwatch_metric_alarm" "foobar" {
alarm_name = "%s"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use the same way to name resources as other tests (e.g. for future sweepers) in this file?
(it's just me trying to keep consistency between tests as much as possible! 😄 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem about this, I'll switch it to rInt for consistency with the other tests.

Something I think that would be really helpful in the future is switching the testing to include the test names so we can easily find "bad apples". Just jumped the gun a little bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bflad totally agree on that :)
Was just wondering on this specific question why we were using t.Name() rather than what we do elsewhere: you may had a good reason :)

* Use rInt and fix indentation in new datapoints_to_alarm test for consistency
* Remove extraneous period in datapoints_to_alarm documentation
@bflad
Copy link
Contributor Author

bflad commented Dec 22, 2017

PR updated! 🚀

@Ninir
Copy link
Contributor

Ninir commented Jan 3, 2018

Hey @bflad

Happy new year! :)

This looks good to me! thanks for the work! 🚀 ⭐️

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudWatchMetricAlarm'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCloudWatchMetricAlarm -timeout 120m
=== RUN   TestAccAWSCloudWatchMetricAlarm_importBasic
--- PASS: TestAccAWSCloudWatchMetricAlarm_importBasic (15.92s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_basic
--- PASS: TestAccAWSCloudWatchMetricAlarm_basic (12.95s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm
--- PASS: TestAccAWSCloudWatchMetricAlarm_datapointsToAlarm (13.30s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_treatMissingData
--- PASS: TestAccAWSCloudWatchMetricAlarm_treatMissingData (23.51s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles
--- PASS: TestAccAWSCloudWatchMetricAlarm_evaluateLowSampleCountPercentiles (23.18s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_extendedStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_extendedStatistic (12.02s)
=== RUN   TestAccAWSCloudWatchMetricAlarm_missingStatistic
--- PASS: TestAccAWSCloudWatchMetricAlarm_missingStatistic (5.02s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	105.933s

@Ninir Ninir merged commit 4e8f6e5 into hashicorp:master Jan 3, 2018
@bflad bflad added this to the v1.7.0 milestone Jan 12, 2018
@bflad bflad deleted the cloudwatch_metric_alarm_datapoints branch January 12, 2018 15:45
@bflad
Copy link
Contributor Author

bflad commented Jan 12, 2018

This has been released in terraform-provider-aws version 1.7.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 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 Apr 3, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CloudWatch M out of N Alarm Thresholds
2 participants