Issue with importing 'aws_route53_health_check' module

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
}

Hi @h2oearth,

Aside from the XXXX replacements, is this the exact configuration you are using? If so it should work to import both of the aws_route53_health_check resources. Can you show the actual plan output?