- Newest
- Most votes
- Most comments
As you noted, when creating a hosted zone, AWS Route 53 assigns a random selection of name servers to the hosted zone. The domain registrar must be configured with these name servers as in order to make your domain available on the internet. The documentation on replacing a hosted zone [1] refers to updating the domain registrar to reference these name servers to ensure the correct hosted zone is used to resolve DNS records. This is described in more detail in the documentation page on adding or changing name servers and glue records for a domain [2].
While you can change the NS and SOA records for your AWS Route 53 hosted domains, this is most commonly used for white-labeling your name servers [3] and does not change the AWS Route 53 name servers that are associated with the Hosted Zone by AWS. It only changes the records returned by the hosted zone when queried.
This is why the CDK build fails in your example code: the ZoneDelegationRecord is attempting to create new NS records for the parent domain when those records already exist. The CDK ZoneDelegationRecord [4] construct is used to delegate resolution to child zones, not to change name servers for the parent domain.
If you would like to use the same set of name servers for multiple hosted zones, for example to simplify management, accelerate migration of multiple domains, or have consistent white-labeling across domains, you can use a reusable delegation set [5].
The AWS CDK does not currently have any constructs for creating Reusable Delegation Sets or using a Delegation Set when creating a Public Hosted Zone. There is discussion on this topic on aws/awscdk issue #12756 [6] which includes an example custom resource for creating public hosted zones using a previously created DelegationSet. This concept could be extended with another custom resource for the Reusable Delegation Set using the corresponding AWS Route 53 APIs [7].
[1] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-replace-hosted-zone.html
[2] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-name-servers-glue-records.html
[3] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/white-label-name-servers.html
[4] https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.ZoneDelegationRecord.html
Relevant content
- asked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 years ago
Is there a way to create a HostedZone with custom name servers? Or to update the HostedZone nameservers?
You can't create a HostedZone with custom name servers per se, however you can use reusable delegation sets [1] to have a consistent set of 4 AWS name servers across your HostedZones. This is most commonly used for white-labeling DNS servers consistently across an organization's HostedZones.
[1] https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/route-53-concepts.html#route-53-concepts-reusable-delegation-set