You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Terraform中配置Route53的CNAME Alias记录?目标配置位置存疑

How to Configure Your DNS Record in Terraform for AWS Route53

Hey there, let's clear up the confusion here! First, a key point to understand: Route53 Alias records only work with AWS-managed resources (like ELBs, CloudFront distributions, S3 static websites, or other records within the same Route53 hosted zone). Since your target is an external domain (server.some-external-domain.de), you can't use an Alias record here—you'll need to create a standard CNAME record instead, matching your existing DNS entry.

Here's the Terraform code for your specific record:

resource "aws_route53_record" "something_cname" {
  zone_id = "${aws_route53_zone.your_zone.zone_id}" # Replace with your Route53 zone ID reference
  name    = "something.domainmanagedbyroute53.de"
  type    = "CNAME"
  ttl     = 3600
  records = ["server.some-external-domain."] # Note the trailing dot to avoid zone suffix addition
}

A quick breakdown of the code:

  • zone_id: Replace this with the reference to your Route53 hosted zone (either using a resource reference like ${aws_route53_zone.your_zone.zone_id} or hardcode the zone ID if you prefer)
  • name: Exact subdomain from your original record
  • type: Set to CNAME since we're pointing to an external domain
  • ttl: Matches your original 3600 value
  • records: The target external domain, with a trailing dot to ensure Route53 doesn't append your hosted zone's domain suffix automatically

To clarify why the Alias example from the docs doesn't apply here: that example uses an Alias to point to an AWS ELB, which is an AWS-managed resource. Alias records have benefits like automatic health checks (when applicable) and no TTL limitations, but they're restricted to AWS-owned targets. For external domains, stick with the standard CNAME record as shown above.

内容的提问来源于stack exchange,提问作者user2656732

火山引擎 最新活动