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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:01:08