-
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
[Bug]: aws_cloudwatch_metric_alarm with expression throws: "period": conflicts with metric_query
#29398
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
ValidationError Period must not be null
ValidationError Period must not be null
"period": conflicts with metric_query
HI @cmihail, thanks for submitting this. To clarify, is the error message that you're seeing the following?
That's what I see when I try the example code. |
Hey @gdavison . Yes, sorry, the error I get is:
The previous error was probably from some experimenting code and I copy pasted the wrong error. Though based on AWS docs
|
@gdavison I can provide some additional context to this bug. Tested with 4.57.1 Say I manually make a CloudWatch Alarm
I can import this alarm and show that state as: ❯ terraform import aws_cloudwatch_metric_alarm.test test
❯ terraform state show aws_cloudwatch_metric_alarm.test
# aws_cloudwatch_metric_alarm.test:
resource "aws_cloudwatch_metric_alarm" "test" {
actions_enabled = true
alarm_actions = []
alarm_description = "test"
alarm_name = "test"
arn = "arn:aws:cloudwatch:us-east-1:accountId:alarm:test"
comparison_operator = "GreaterThanOrEqualToThreshold"
datapoints_to_alarm = 1
dimensions = {}
evaluation_periods = 1
id = "test"
insufficient_data_actions = []
ok_actions = []
period = 0
tags = {}
tags_all = {}
threshold = 1
treat_missing_data = "notBreaching"
metric_query {
expression = "SELECT SUM(AuthorizationFailureCount) FROM SCHEMA(CloudTrailMetrics, accountId,region)"
id = "e1"
label = "AuthorizationFailureCount"
return_data = true
}
} Notice
If I remove
I would also like to note that with a Metrics Insights query alarm, the period must be between 1 minute and 3 hours. So I have this alarm set to a period of 60 seconds in the AWS Dashboard, but Terraform imported it as 0 for unknown reasons. |
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 issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Core Version
1.3.1
AWS Provider Version
4.32.0
Affected Resource(s)
aws_cloudwatch_metric_alarm
Expected Behavior
terraform apply
with successActual Behavior
I get the error
"period": conflicts with metric_query
even though https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html mentions that period is now supported insideMetricDataQuery
Also using AWS Console I was able to create the alarm manually with the same expression as the one from above configuration.
The error seems to be due to
period
missing fromterraform-provider-aws/internal/service/cloudwatch/metric_alarm.go
Line 599 in 5857c14
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
Define
var.app_name
using the name of a KCL kubernates application and then create a new CW alarm with period inside meric_query (see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-alarm-metricdataquery.html for documentation).Debug Output
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: