Hi Terraform Gurus!
Although the ids are correct, the plan shows that two resources are going to be created instead of imported.
Any idea what could be wrong?
This is my current file structure
/app.tf
/module/r53/r53.tf
app.tf
locals {
healthchecks = [
{
distribution = "dist1"
id = "XXXXf534-4f69-43cf-XXXXXXXX"
},
{
distribution = "dist2"
id = "XXXX213-52a9-435f-XXXXXXX"
},
]
}
import {
for_each = { for i, obj in local.healthchecks : obj.distribution => obj }
to = module.r53.aws_route53_health_check.this[each.value.distribution]
id = each.value.id
}
r53.tf
locals {
healthchecks = [
{
distribution = "dist1"
id = "XXXXf534-4f69-43cf-XXXXXXXX"
},
{
distribution = "dist2"
id = "XXXX213-52a9-435f-XXXXXXX"
},
]
}
resource "aws_route53_health_check" "this" {
for_each = { for i, obj in local.healthchecks : obj.distribution => obj }
reference_name = each.value.distribution
fqdn = each.value.distribution
port = 443
type = "HTTPS"
resource_path = "/status/health"
failure_threshold = 1
request_interval = 30
}