"DNS": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"HostedZoneId" : "Z058101PST6709",
"RecordSets" : [{
"Name" : {
"Ref": "AlternateDomainNames"
},
"Type" : "CNAME",
"TTL" : "900",
"ResourceRecords" : {
"Ref": "myDistribution"
},
"Weight" : "140"
}]
}
}
您好,我要用cloudfront创建route53记录,请找到云形成代码,并且在创建堆栈时出现错误。基本上,我想通过使用Cloudfront域名来创建CNAME记录。请帮助我。
您可以使用以下模板
"DNS": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"HostedZoneId": "Z058101PST6709",
"Name": {
"Ref": "AlternateDomainNames"
},
"ResourceRecords": [{ "Fn::GetAtt": ["myDistribution", "DomainName"] }],
"TTL": "900",
"Type": "CNAME"
}
}
当您使用Route 53时,我应该提出,您应该利用Alias records而不是CNAME
记录作为CloudFront分配。
这可以通过下面的方法完成。
{
"Type": "AWS::Route53::RecordSetGroup",
"Properties": {
"HostedZoneId": "Z058101PST6709",
"RecordSets": [{
"Name": {
"Ref": "AlternateDomainNames"
},
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z2FDTNDATAQYW2",
"DNSName": { "Fn::GetAtt": ["myDistribution", "DomainName"] }
}
}]
}
}