Error: no matching Route53Zone found: when attempting to link Route53 to an Amazon load balancer

Error: no matching Route53Zone found: when attempting to link Route53 to an Amazon load balancer

假设我有一个 public 托管区域 service.example.com.。我们让此代码在包含 API 网关的配置中工作。我们已决定将 CNAME 别名绑定到 ECS 集群前面的 ALB/NLB。我们打算稍后向 ALB/NLB 添加证书并放入 WAF。但是,我们需要先完成这项工作,然后再转到那些。

此托管区域存储在变量 domain_suffix 中,不带点 service.example.com。 我正在为 ALB/NLB 及其与 ECS 的集成使用自定义 terraform 模块。

data "aws_route53_zone" "public_zone" {
  name         = var.domain_suffix
  private_zone = false
}

在 terraform plan 期间出现此错误:

Error: no matching Route53Zone found

  on ../prod/modules/regional-service/data.tf line 12, in data "aws_route53_zone" "public_zone":
  12: data "aws_route53_zone" "public_zone" {

Route53代码如下:

resource "aws_route53_record" "a-record" {
  name    = local.regional_subdomain
  type    = "A"
  zone_id = data.aws_route53_zone.public_zone.id

  alias {
    name                   = data.aws_lb.bridged-lb.dns_name
    zone_id                = data.aws_lb.bridged-lb.zone_id
    evaluate_target_health = true
  }
}

resource "aws_route53_health_check" "health_check" {
  port          = 443
  type          = "HTTPS"
  resource_path = "/version"

  fqdn = local.regional_subdomain

  failure_threshold = "5"
  request_interval  = "30"

  tags = local.tags
}

resource "aws_route53_record" "cname" {
  name            = local.global_subdomain
  records         = [local.regional_subdomain]
  set_identifier  = "${var.service_name}-${var.region}"
  ttl             = "60"
  type            = "CNAME"
  zone_id         = data.aws_route53_zone.public_zone.id
  health_check_id = aws_route53_health_check.health_check.id

  latency_routing_policy {
    region = var.region
  }
}

对于解决此问题的任何帮助,我将不胜感激。 非常感谢您。

在@ydaetskcoR 的帮助下,我再次查看了代码,发现我引用了错误的 AWS 账户。我立即获得了正确的帐户信息和相应的 public 托管区域,我的 CI/CD 管道过程继续顺利完成。