How do I import DNS zone files to Route 53 and troubleshoot errors received while importing them?

Last updated: 2021-04-02

I'm migrating my Domain Name System (DNS) from another service provider. I need to move all the records in an Amazon Route 53 hosted zone by importing a DNS zone file. How can I do this?

Short description

Before importing a DNS zone file, consider the following:

  • The zone file must be in an RFC-compliant format.
  • The domain name of the records in the zone file must match the name of the hosted zone.
  • Route 53 supports the $ORIGIN and $TTL keywords. If the zone file includes $GENERATE or $INCLUDE keywords, the import fails and Route 53 returns an error.
  • When you import the zone file, Route 53 ignores the statement of authority (SOA) record. Any name server (NS) records in the zone file that have the same name as the hosted zone are also ignored.
  • You can import a maximum of 1,000 records. To import more than 1,000 records, see BIND to Amazon Route 53 conversion tool.
  • If the hosted zone already contains records that appear in the zone file, the import process fails, and no records are created.
  • Review the contents of the zone file to confirm that record names include or exclude a trailing dot, as appropriate.
    • When the name of a record in the zone file includes a trailing dot (example.com.), the import process interprets the name as a fully qualified domain name (FQDN). In this case, a Route 53 record with that name is created.
    • When the name of a record in the zone file doesn't include a trailing dot (www), the import process concatenates that name with the domain name in the zone file (example.com). In this case, a Route 53 record with the concatenated name (www.example.com) is created.

Note: For canonical name (CNAME), mail exchanger (MX), pointer (PTR), and service (SRV) records, this behavior also applies to the domain name that's included in the RDATA value. For example, suppose you have a zone file for example.com. If a CNAME record in the zone file (support, without a trailing dot) has an RDATA value of www.example.com (also without a trailing dot), then the import process creates a Route 53 record with the name support.example.com. This record routes traffic to www.example.com.example.com. Before you import your zone file, review RDATA values and update them, as applicable.

Resolution

Import a DNS zone file

To create records by importing a zone file:

  1. Open the Route 53 console.
  2. In the navigation pane, choose Hosted zones.
  3. On the Hosted zones page, choose Create hosted zone.
  4. Enter the name of your domain. (Optional) You can also enter a comment.
  5. Choose Create.
  6. Choose Import zone file.
  7. In the Import zone file pane, paste the contents of your zone file into the Zone file text box.
  8. Choose Import.

Note: Depending on the amount of records in your zone file, it might take a few minutes for the records to be created.

After the DNS records are created in the Route 53 hosted zone, you can proceed with the migration process. To complete the migration process, follow the steps in Making Amazon Route 53 the DNS service for an existing domain.

Troubleshoot errors received while importing a DNS zone file

The following examples provide troubleshooting steps for resolving common error messages that you might receive while importing DNS zone files.

"Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with {DNS_Record}"

Cause: There's no time to live (TTL) value specified in a DNS record of the zone file.

Example zone file:

$ORIGIN testdomain.com
@ A 1.1.1.1
www CNAME example.com

Example error message:

Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but 
found none in Change with [Action=CREATE, Name=testdomain.com, Type=A, SetIdentifier=null]

Solution: Either use the $TTL keyword to assign TTL to all the DNS records or specify a TTL value to individual records, as appropriate for your use case.

$ORIGIN testdomain.com
$TTL 60
@ A 1.1.1.1
www CNAME example.com

-or-

$ORIGIN testdomain.com
@ 60 A 1.1.1.1
www 60 CNAME example.com

"The zone file contains too many values for a record with a type of {Record_Type}. 1 values were expected, but {n} values are specified. On line {m}."

Cause: Multiple values were specified for a particular DNS record in line "m."

Example 1 zone file:

$ORIGIN testdomain.com
$TTL 60
@ TXT  "abc" "xyz"

Example 1 error message:

The zone file contains too many values for a record with a type of TXT. 1 
values were expected, but 2 values are specified. On line 3. '@ TXT  
"abc" "xyz"'

Solution: Specify multiple TXT record values on separate lines. Be sure to use double quotes ("example value") around each value.

$ORIGIN testdomain.com
$TTL 60
@ TXT "abc" 
@ TXT "xyz"

Example 2 zone file:

$ORIGIN testdomain.com
$TTL 60
@ A 1.1.1.1 2.2.2.2 3.3.3.3

Example 2 error message:

The zone file contains too many values for a record with a type of A. 1 
values were expected, but 3 values are specified. On line 3. '@ A 
1.1.1.1 2.2.2.2 3.3.3.3'

Solution:

$ORIGIN testdomain.com
$TTL 60
@ A 1.1.1.1 
@ A 2.2.2.2
@ A 3.3.3.3

"CharacterStringTooLong (Value is too long) encountered with {Value}"

Cause: The TXT value string contains more than 255 characters.

Example zone file:

$ORIGIN testdomain.com
$TTL 60
www TXT "spf1 +a +mx ip4:1.1.1.1 ip4:2.2.2.2 ip4:3.3.3.3 ip4:4.4.4.4 ip4:5.5.5.5.5 ip4:6.6.6.6 ip4:7.7.7.7 ip4:8.8.8.8 ip4:9.9.9.9 ip4:10.10.10.10 ipv4:11.11.11.11 ip4:12.12.12.12 ip4:13.13.13.13 ip4:14.14.14.14 ip4:15.15.15.15.15 include:spf.abc.com include:_spf.xyz.com ~all"

Example error message:

[Invalid Resource Record: 'FATAL problem: 
CharacterStringTooLong (Value is too long) encountered with '"spf1 +a 
+mx ip4:1.1.1.1 ip4:2.2.2.2 ip4:3.3.3.3 ip4:4.4.4.4 ip4:5.5.5.5.5 
ip4:6.6.6.6 ip4:7.7.7.7 ip4:8.8.8.8 ip4:9.9.9.9 ip4:10.10.10.10 
ipv4:11.11.11.11 ip4:12.12.12.12 ip4:13.13.13.13 ip4:14.14.14.14 
ip4:15.15.15.15.15 include:spf.abc.com include:_spf.xyz.com ~all"'']

Solution: Split TXT record strings with over 255 characters into multiple text strings within the same record. Be sure to use double quotes ("example value") around each value.

$ORIGIN testdomain.com
$TTL 60
www TXT "spf1 +a +mx ip4:1.1.1.1 ip4:2.2.2.2 ip4:3.3.3.3 ip4:4.4.4.4 ip4:5.5.5.5.5 ip4:6.6.6.6 ip4:7.7.7.7 ip4:8.8.8.8 ip4:9.9.9.9 ip4:10.10.10.10 ipv4:11.11.11.11""ip4:12.12.12.12 ip4:13.13.13.13 ip4:14.14.14.14 ip4:15.15.15.15.15 include:spf.abc.com include:_spf.xyz.com ~all"

Note: The maximum length of a value in a TXT record is 4,000 characters.

"RRSet of type CNAME with DNS name example.com does not contain exactly one resource record"

Cause: Multiple CNAME records were created for the same domain name.

Note: Records imported to a hosted zone using this method are created with the Simple Routing policy. As a result, multiple CNAME records can't be specified in a single DNS record.

Example zone file:

$ORIGIN testdomain.com
$TTL 60
www CNAME abc.com
www CNAME xyz.com

Example error message:

Error occurred [RRSet of type CNAME with DNS name www.testdomain.com. is not permitted as it 
conflicts with other records with the same DNS name in zone 
testdomain.com., RRSet of type CNAME with DNS name www.testdomain.com. 
does not contain exactly one resource record.]

Solution: Instead of using the Import option, create records separately with Weighted, Latency, Failover, or Geolocation routing policies, as appropriate for your use case.


Did this article help?


Do you need billing or technical support?