我正在尝试使用 Terraform 0.12.0 创建 ACM 证书以应用于我的 Amazon ALB。我可以在没有证书的情况下毫无问题地创建我的 ALB。整个基础架构堆栈按预期构建和部署。现在,我添加了以下代码来创建 Route 53 验证记录、请求证书并将其分配给新的 ALB 侦听器:
资源 "aws_route53_zone" "main" { name = "${var.zone_name}" }
resource "aws_route53_record" "validation" {
name = "${aws_acm_certificate.main.domain_validation_options.0.resource_record_name}"
type = "${aws_acm_certificate.main.domain_validation_options.0.resource_record_type}"
zone_id = "${aws_route53_zone.main.zone_id}"
records = ["${aws_acm_certificate.main.domain_validation_options.0.resource_record_value}"]
ttl = "60"
}
resource "aws_acm_certificate_validation" "main" {
certificate_arn = "${aws_acm_certificate.main.arn}"
validation_record_fqdns = "${aws_route53_record.validation.*.fqdn}"
}
resource "aws_alb_listener" "front_end_tls" {
load_balancer_arn = "${aws_alb.main.id}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016–08"
certificate_arn = "${var.certificate_arn}"
default_action {
target_group_arn = "${aws_alb_target_group.main.id}"
type = "forward"
}
}
但是,当我运行terraform apply
时,它似乎卡在了证书验证上。我看到这样的消息:
module.dns.aws_acm_certificate_validation.main: Still creating... [38m21s elapsed]
我已经让代码运行了超过 45 分钟,直到我最终看到一条错误消息:
Error: Error creating LB Listener: SSLPolicyNotFound: SSL policy 'ELBSecurityPolicy-2016–08' not found
status code: 400, request id: a5f052c1-86df-11e9-993c-f99526fa9bba
on alb/main.tf line 25, in resource "aws_alb_listener" "front_end_tls":
25: resource "aws_alb_listener" "front_end_tls" {
Error: Expected certificate to be issued but was in state PENDING_VALIDATION
on dns/main.tf line 38, in resource "aws_acm_certificate_validation" "main":
38: resource "aws_acm_certificate_validation" "main" {
如果我登录到控制台,我会看到证书请求仍处于 Pending Validation 状态。我还看到了按预期创建的 Route 53 验证记录。
为什么从未处理和应用此证书请求?我的 Terraform 代码中是否缺少某些内容?
更新: 当我使用现有的 Route 53 区域(与我在上面尝试的域名不同的域名)并将其作为我的数据资源引用时aws_route53_record
,它可以正常工作。我在这个测试中尝试的域名是今天通过 Route 53 购买的,所以我想知道这是否与我的问题有关。我无法对任何记录进行 nslookup,即使我看到它们在 Route 53 控制台中列出。也许?我会让它静置几天,看看它是否只是时间问题。