简体   繁体   English

通过 Cloudfront 在 cloudformation 中使用 Route53 模板

[英]Use Route53 template in cloudformation with Cloudfront

"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.嗨团队,我将使用 cloudfront 创建一个 route53 记录,请找到云形成代码,我在创建堆栈时遇到错误。 Basically I want to create a CNAME record by using cloudfront domain name.基本上我想通过使用云端域名创建一个 CNAME 记录。 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.我应该提出,当您使用 Route 53 时,您应该利用别名记录而不是CNAME记录来进行 CloudFront 分配。

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"] }
            }
        }]
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果可以使用AWS Cloudformation模板将Loadbalancers DNSname连接到Route53? - If it possible connect Loadbalancers DNSname to Route53 using AWS Cloudformation template? 使用Route53在“Cloudformation”中遇到“遇到不受支持的属性类型”错误 - “Encountered unsupported property Type” Error in Cloudformation with Route53 使用 AWS CloudFormation json 创建堆栈时 AWS::Route53::RecordSet 中出现无效请求错误 - Invalid request error in AWS::Route53::RecordSet when creating stack with AWS CloudFormation json 如何在As route53中获取具有相同名称的HostedZone的HostedZoneId? - How to get the HostedZoneId of a HostedZone in As route53 with same name? 将多个元素更新到AWS Route 53 JSON模板 - Updating Multiple Elements to AWS Route 53 JSON Template 我可以在 AWS Cloudformation json 模板的“参数”中使用“Fn::Join”吗 - Can I use "Fn::Join" in "Parameters" of AWS Cloudformation json template 将 cloudformation 模板移植到 terraform - Porting a cloudformation template to terraform 使用 cloudformation 在云端添加 ssl 证书时出现错误(需要指定) - Geeting error in adding ssl certificate in cloudfront using cloudformation (needs to be specified) 向AWS Route 53 JSON添加元素 - Adding Elements to AWS Route 53 JSON 使用 Route 53 CLI 删除记录 - Using Route 53 CLI to delete records
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM