如何为 ALB 创建 Route 53 记录?(AWS) [英] How can I create a Route 53 Record to an ALB? (AWS)

查看:68
本文介绍了如何为 ALB 创建 Route 53 记录?(AWS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个新的 alb 和一个指向它的 route53 记录.

I want to create a new alb and a route53 record that points to it.

我看到我有 DNS 名称:${aws_lb.MYALB.dns_name}

I see I have the DNS name: ${aws_lb.MYALB.dns_name}

是否可以使用 aws_route53_record 资源为公共 DNS 名称创建 cname?

Is it possible to create a cname to the public DNS name with aws_route53_record resource?

推荐答案

参见 Terraform Route53 记录文档

您可以使用以下内容添加基本的 CNAME 条目:

You can add a basic CNAME entry with the following:

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]
}

或者如果您使用的是顶点"域(例如 example.com)考虑使用别名(AWS 别名文档):

Or if you're are using an "apex" domain (e.g. example.com) consider using an Alias (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
  }
}

这篇关于如何为 ALB 创建 Route 53 记录?(AWS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆