Terraform - Error: no matching Route53Zone found

Terraform - Error: no matching Route53Zone found

我使用 https://github.com/cloudposse/terraform-aws-acm-request-certificate 使用 terraform 和 aws 生成证书。

我想 运行 这个模块在服务域上:“example.com”,“cdn.example.com”...

我不想用subject_alternative_names代替cdn.example.com,因为它会出现在证书里面的subject字段,大家打开证书的时候我不想想让他看看cdn域名。

对于cdn。example.com我想要一个新证书。

所以我尝试使用下面的代码 运行 terraform apply,但出现错误:

Error: no matching Route53Zone found

on .terraform\modules\acm_request_certificate_example\main.tf line 19, in data "aws_route53_zone" "default": 19: data "aws_route53_zone" "default" {

Error: no matching Route53Zone found

on .terraform\modules\acm_request_certificate_cdn_example\main.tf line 19, in data "aws_route53_zone" "default": 19: data "aws_route53_zone" "default" {

我不能运行 more 模块吗?无论如何如何解决?

main.tf

terraform {
  required_version = "~> 0.12.0"
}

provider "aws" {
  version = "~> 2.12.0"
  region  = "us-east-1"
}
module "acm_request_certificate_example" {
  source                            = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
  domain_name                       = "example.com"
  process_domain_validation_options = true
  ttl                               = "300"
}

module "acm_request_certificate_cdn_example" {
  source                            = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
  domain_name                       = "cdn.example.com"
  process_domain_validation_options = true
  ttl                               = "300"
}

我在托管区域中只有 example.com

根据评论。

问题是由使用 process_domain_validation_options = true 引起的。这会在请求证书之前检查 Roure53 中 托管区域是否存在 。这样做是为了启用要颁发的 SSL 证书的自动验证

由于在 OP 的情况下,为没有相应区域的域请求 SSL 证书,terraform 出错了。

解决方案是使用 process_domain_validation_options = false,但这需要 手动验证 过程才能颁发 SSL。要使此过程自动化,必须通过自定义解决方案来完成。从广义上讲,此类解决方案可能涉及使用 aws_route53_record, a lambda function or local-exec 供应商创建所需记录以进行验证的创建所需记录。