Reputation: 16673
Terraform v0.12.x
I'm trying to create a Route53 record with this script, which aims to create an A record that's aliased to an ALB.
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
}
}
The plan shows the correct values I expect
$ terraform plan -out out.output
But when I apply the plan I get
$ 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
If I go to the AWS Route53 console, I can create the record. What am I missing?
Upvotes: 2
Views: 1401
Reputation: 925
Try using zone_id
from aws_lb.jenkins_master_green
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
}
}
Upvotes: 5