gpt4 book ai didi

Terraform 无法创建 AWS Route53 记录,但我可以手动创建它吗?

转载 作者:行者123 更新时间:2023-12-03 08:32:19 25 4
gpt4 key购买 nike

Terraform v0.12.x

我正在尝试使用此脚本创建一条 Route53 记录,该脚本旨在创建一条 ALB 别名的 A 记录。

data "aws_route53_zone" "mycompany_com" {
name = "mycompany.com."
private_zone = true
}

resource "aws_route53_record" "jenkins_master_green" {
zone_id = data.aws_route53_zone.mycompany_com.zone_id
name = "jenkins-green.${data.aws_route53_zone.mycompany_com.name}"
type = "A"
alias {
name = aws_lb.jenkins_master_green.dns_name
zone_id = data.aws_route53_zone.mycompany_com.zone_id
evaluate_target_health = false
}
}

该计划显示了我期望的正确值

$ terraform plan -out out.output

但是当我应用该计划时,我得到了

$ terraform apply out.output
aws_route53_record.jenkins_master_green: Creating...

Error: [ERR]: Error building changeset: InvalidChangeBatch: [Tried to create an alias that targets <redacted>.us-east-1.elb.amazonaws.com., type A in zone <redacted>, but the alias target name does not lie within the target zone, Tried to create an alias that targets <redacted>.us-east-1.elb.amazonaws.com., type A in zone <redacted>, but that target was not found]
status code: 400, request id: 2cf7384d-fa16-4828-854b-ea3e56cc0754

如果我转到 AWS Route53 控制台,我可以创建记录。我错过了什么?

最佳答案

尝试使用 aws_lb.jenkins_master_green 中的 zone_id

data "aws_route53_zone" "mycompany_com" {
name = "mycompany.com."
private_zone = true
}

resource "aws_route53_record" "jenkins_master_green" {
zone_id = data.aws_route53_zone.mycompany_com.zone_id
name = "jenkins-green.${data.aws_route53_zone.mycompany_com.name}"
type = "A"
alias {
name = aws_lb.jenkins_master_green.dns_name
zone_id = aws_lb.jenkins_master_green.zone_id
evaluate_target_health = false
}
}

关于Terraform 无法创建 AWS Route53 记录,但我可以手动创建它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64762560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com