I’m creating Cloudwatch alarms, which have two conflicting attributes: statistic and extended_statistic. However, I’m creating them dynamically reading from a list of maps, resulting in the following code:
variables.tfvars:
cloudwatch_alarms = {
foo = {
statistic = "Average"
}
bar = {
extended_statistic = "p60"
}
}
main.tf:
resource "aws_cloudwatch_metric_alarm" "cloudwatch_alarms" {
for_each = var.cloudwatch_alarms
statistic = each.value["statistic"]
extended_statistic = each.value["extended_statistic"]
// won't work, attribute conflict with "statistic"
}
How could I have both attributes in my map and use them conditionally inside my resource?