I'd like to create a Route53 Hosted Zone for a subdomain and NS
record to parent domain.
Let's say I have:
example.com
and I want a hosted zone for subdomain:
build.example.com
Hosted Zone creation works:
ClusterHostedZone:
Type: "AWS::Route53::HostedZone"
Properties:
Name: !Ref DomainName
HostedZoneConfig:
Comment: Managed by Cloud Formation
HostedZoneTags:
- Key: KubernetesCluster
Value: !Ref KubernetesCluster
Delegating responsibility for the subdomain don't:
ParentHostedZoneClusterRecord:
Type: "AWS::Route53::RecordSet"
Properties:
Name: !Ref DomainName
Comment: Managed by Cloud Formation
HostedZoneId: !Ref ParentHostedZoneID
TTL: 30
Type: NS
ResourceRecords: !GetAtt ClusterHostedZone.NameServers
This is not implemented and I don't know how to get this information:
ResourceRecords: !GetAtt ClusterHostedZone.NameServers
Is this simple feature just missing in Cloud Formation?
You can create more than one hosted zone with the same name and add different records to each hosted zone. Route 53 assigns four name servers to every hosted zone, and the name servers are different for each hosted zone.
This is working for my, maybe your template is not working because you do not specify DependsOn
and resources are not created in order.
stagingHostedZone:
Type: 'AWS::Route53::HostedZone'
Properties:
HostedZoneConfig:
Comment: Hosted zone for staging environment
Name: staging.example.com
nsRootHostedZoneRecordSet:
Type: 'AWS::Route53::RecordSet'
Properties:
HostedZoneId: Z25*********
Name: staging.example.com.
Type: NS
TTL: '900'
ResourceRecords: !GetAtt stagingHostedZone.NameServers
DependsOn:
stagingHostedZone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With