我想创建一个新的alb和一个指向它的route53记录。
我看到我有DNS名称:${aws_lb.MYALB.dns_name}
是否可以使用aws_route53_record资源为公用DNS名称创建cname?
最佳答案
请参见Terraform Route53 Record docs
您可以使用以下内容添加基本的CNAME条目:
resource "aws_route53_record" "cname_route53_record" {
zone_id = "${aws_route53_zone.primary.zone_id}" # Replace with your zone ID
name = "www.example.com" # Replace with your subdomain, Note: not valid with "apex" domains, e.g. example.com
type = "CNAME"
ttl = "60"
records = ["${aws_lb.MYALB.dns_name}"]
}
或者,如果您使用的是“ apex”域(例如example.com),请考虑使用别名(AWS Alias Docs):
resource "aws_route53_record" "alias_route53_record" {
zone_id = "${aws_route53_zone.primary.zone_id}" # Replace with your zone ID
name = "example.com" # Replace with your name/domain/subdomain
type = "A"
alias {
name = "${aws_lb.MYALB.dns_name}"
zone_id = "${aws_lb.MYALB.zone_id}"
evaluate_target_health = true
}
}
关于terraform - 如何创建到alb的route53记录?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48919317/