"DNS": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"HostedZoneId" : "Z058101PST6709",
"RecordSets" : [{
"Name" : {
"Ref": "AlternateDomainNames"
},
"Type" : "CNAME",
"TTL" : "900",
"ResourceRecords" : {
"Ref": "myDistribution"
},
"Weight" : "140"
}]
}
}
Hi Team, I am going to create a route53 record with cloudfront please find the cloud-formation code and in which I am getting an error while create a stack. Basically I want to create a CNAME record by using cloudfront domain name. Please help me out in this.
You can use the below template
"DNS": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"HostedZoneId": "Z058101PST6709",
"Name": {
"Ref": "AlternateDomainNames"
},
"ResourceRecords": [{ "Fn::GetAtt": ["myDistribution", "DomainName"] }],
"TTL": "900",
"Type": "CNAME"
}
}
I should raise as you're using Route 53 you should take advantage of using Alias records instead of CNAME
records for your CloudFront Distribution.
This could be done via the below.
{
"Type": "AWS::Route53::RecordSetGroup",
"Properties": {
"HostedZoneId": "Z058101PST6709",
"RecordSets": [{
"Name": {
"Ref": "AlternateDomainNames"
},
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z2FDTNDATAQYW2",
"DNSName": { "Fn::GetAtt": ["myDistribution", "DomainName"] }
}
}]
}
}
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