How to get multiple ids from aws_route53_health_check in aws_cloudwatch_metric_alarm dimensions?

Hi everyone,
i’m in trouble to get multiples aws_route53_health_check ids for my cloudwatch metric alarms:

I’ve create this route53 health checks:

resource “aws_route53_health_check” “this” {
for_each = local.health_check

fqdn = each.value.fqdn
port = 80
type = “HTTP”
resource_path = “/healthy.html”
failure_threshold = “3”
request_interval = “10”
measure_latency = true

tags = merge(local.TF_tag, {
Name = each.value.tag_name
})
}

with this locals:

locals {
health_check = {
“app-alb1” = { fqdn = “{data.aws_route53_zone.selected.name}", tag_name = "app-healthcheck_1" }, "app-alb2" = { fqdn = "www.{data.aws_route53_zone.selected.name}”, tag_name = “app-healthcheck_2” }
}
}

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

and then i want to join these cloudwatch metric alarms :

resource “aws_cloudwatch_metric_alarm” “app-alb-health-check” {
for_each = local.app-alb-health-check

alarm_name = “${each.key}_app-alb-health-check”
comparison_operator = “GreaterThanOrEqualToThreshold”
evaluation_periods = 1
metric_name = each.key
namespace = “AWS/Route53”
period = 60
statistic = “Average”
threshold = each.value.threshold

tags = merge(local.TF_tag, {
Name = “${each.key}_app-alb-health-check”
})

dimensions = {
HealthCheckId = aws_route53_health_check.this.*.id <----- the problem is here!

}
alarm_actions = [module.app-alb-health-check_sns_topic.sns_topic_arn]
}

with this locals:

locals {
app-alb-health-check = {
HealthCheckStatus = {
threshold = 0.99
},
HealthCheckPercentageHealthy = {
threshold = 99
}
}
}

I’ve this errors:
aws_route53_health_check.this is object with 2 attributes

│ Inappropriate value for attribute “dimensions”: element “HealthCheckId”: string required.

This object does not have an attribute named “id”.

I will really appreciate that someone can help me here :slight_smile:

Cedric.