Linked Github issue: aws_cloudwatch_metric_alarm "metric" "stat" no longer accepts percentiles (ie. p95) · Issue #19737 · hashicorp/terraform-provider-aws · GitHub
Terraform CLI and Terraform AWS Provider Version
Terraform v0.12.31
- provider.aws v3.44.0
Affected Resource(s)
- aws_cloudwatch_metric_alarm
- specifically metric.stat
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
resource "aws_cloudwatch_metric_alarm" "p95" {
count = 1
alarm_name = format("%s-p95-%s-api-gateway", "env", "xxx")
alarm_description = "This metric monitors the xxx service api gateway for the P95 going above a threshold."
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 1
threshold = 1
alarm_actions = []
ok_actions = []
treat_missing_data = "ignore"
metric_query {
id = "duration"
label = "API GW duration (ms)"
return_data = true
metric {
metric_name = "Duration"
namespace = "AWS/ApiGateway"
period = "60"
stat = "p95"
dimensions = { ApiName = environment-xxx }
}
}
tags = local.common_tags
}
Expected Behavior
Running terraform plan / terraform apply should deploy infrastructure properly and the “p95” alarm should work with stat = “p95” This was working in v3.43.0 and just recently broke in v3.44.0
Actual Behavior
When running terraform apply on aws provider v3.44.0, we now get this error:
Error: expected metric_query.0.metric.0.stat to be one of [SampleCount Average Sum Minimum Maximum], got p95
on ../../../cloudwatch_api_gateway.tf line 69, in resource "aws_cloudwatch_metric_alarm" "p95":
69: resource "aws_cloudwatch_metric_alarm" "p95" {
Steps to Reproduce
terraform apply
Questions
I have seen https://registry.terraform.io/providers/hashicorp/aws/3.42.0/docs/resources/cloudwatch_metric_alarm#stat
- I understand that this says only “SampleCount, Average, Sum, Minimum, Maximum” are supported, but “p95” also worked all the way up until v3.44.0
- Was there are breaking change in v3.44.0 in regards to this?
- Is this going to be reverted/fixed, or do we need to refactor our code and not be able to use percentiles anymore?