You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Route53域名正确添加DNS记录?API参数适配疑问

你用错API啦!要添加A记录得用这个模板

Hey there, let's get this sorted out quickly—you're trying to use the wrong AWS API for your task!

The updateDomainNameservers API you referenced is only for changing the authoritative nameservers associated with your domain (like switching from Route53's default NS servers to a third-party DNS provider). It has nothing to do with adding individual DNS records (like your A record) to a Route53 hosted zone.

Correct API to Use: ChangeResourceRecordSets

To add your root (@) A record, you need to use Route53's ChangeResourceRecordSets API instead. Here's the parameter template tailored exactly to your needs:

var params = {
  HostedZoneId: 'YOUR_ROUTE53_HOSTED_ZONE_ID', // Replace with your hosted zone ID (find this in Route53 console)
  ChangeBatch: {
    Comment: 'Adding root A record for my domain',
    Changes: [
      {
        Action: 'CREATE', // Use 'UPSERT' instead if you want to overwrite an existing root A record
        ResourceRecordSet: {
          Name: 'yourdomain.com', // "@" translates to your full root domain (e.g., example.com)
          Type: 'A',
          TTL: 300, // Replace with your desired TTL value
          ResourceRecords: [
            {
              Value: '192.168.1.1' // Replace with your target IP address
            }
          ]
        }
      }
    ]
  }
};

Key Notes to Keep in Mind:

  • HostedZoneId: You must specify the ID of the Route53 hosted zone linked to your domain. You can grab this from the Route53 console's "Hosted Zones" section.
  • Action: Use CREATE if this is a brand-new record. If there's already a root A record and you want to update it, use UPSERT (it will create the record if it doesn't exist, or update it if it does).
  • Name: The @ in DNS records refers to the root domain, so you need to input your full domain name here (not just "@").

Critical Warning:

Don't use the updateDomainNameservers API for this task! Modifying your domain's nameservers will redirect all DNS queries for your domain to a new set of servers—this would break all existing DNS records unless you've fully migrated them to the new nameservers.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:15:39