Amazon web services AWS示例模板:S3_网站_和_CloudFront_发行版。模板在开始发送53域名时失败
我正在使用AWS示例模板,从中我减少了一点映射,但保留了所有其他内容。在查看代码并阅读模板中的注释时,我似乎可以通过在运行堆栈时的参数字段中输入我已向Route 53注册的主机区域的名称来运行代码。我还通过ACM创建了证书 然而,我得到了以下错误: 要将备用域名(CNAME)添加到CloudFront发行版,您必须附加一个可信证书,以验证您使用该域名的授权。有关更多详细信息,请参阅:(服务:AmazonCloudFront;状态代码:400;错误代码:InvalidViewerCertificate;请求ID:------------)Amazon web services AWS示例模板:S3_网站_和_CloudFront_发行版。模板在开始发送53域名时失败,amazon-web-services,amazon-s3,amazon-cloudformation,amazon-cloudfront,Amazon Web Services,Amazon S3,Amazon Cloudformation,Amazon Cloudfront,我正在使用AWS示例模板,从中我减少了一点映射,但保留了所有其他内容。在查看代码并阅读模板中的注释时,我似乎可以通过在运行堆栈时的参数字段中输入我已向Route 53注册的主机区域的名称来运行代码。我还通过ACM创建了证书 然而,我得到了以下错误: 要将备用域名(CNAME)添加到CloudFront发行版,您必须附加一个可信证书,以验证您使用该域名的授权。有关更多详细信息,请参阅:(服务:AmazonCloudFront;状态代码:400;错误代码:InvalidViewerCertifica
{
“AWSTemplateFormatVersion”:“2010-09-09”,
“说明”:"AWS CloudFormation示例模板S3\u Website\u和\u CloudFront\u发行版:示例模板显示如何创建具有自定义DNS名称的网站,托管在Amazon S3上,并通过Amazone CloudFront提供服务。它假设您已经有一个托管区域注册到Amazon Route 53。**警告**此模板创建一个Amazon Route 53 DNS记录,即S3bucket和CloudFront发行版。如果您使用此模板创建堆栈,您将为所使用的AWS资源付费。“,
“参数”:{
“HostedZone”:{
“类型”:“字符串”,
“描述”:“现有Amazon Route 53托管区域的DNS名称”,
“AllowedPattern:“(?!-)[a-zA-Z0-9-.]{1,63}(?这是因为您应该为您尝试添加的备用域拥有SSL证书。您可以在us-east-1
地区请求ACM
公共证书
我建议您在cloudformation之外设置ACM证书,因为创建ACM证书需要手动DNS/电子邮件验证
希望这有帮助
参考:
是的,我认为这也是正确的。我确实通过ACM为相关的主机区域创建了一个公共证书。最终故障并向AWS支持提交了一个问题,他们能够使用我的证书和区域信息复制问题。等待发布他们的发现。
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template S3_Website_With_CloudFront_Distribution: Sample template showing how to create a website with a custom DNS name, hosted on Amazon S3 and served via Amazone CloudFront. It assumes you already have a Hosted Zone registered with Amazon Route 53. **WARNING** This template creates an Amazon Route 53 DNS record, an S3 bucket and a CloudFront distribution. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"HostedZone" : {
"Type" : "String",
"Description" : "The DNS name of an existing Amazon Route 53 hosted zone",
"AllowedPattern" : "(?!-)[a-zA-Z0-9-.]{1,63}(?<!-)",
"ConstraintDescription" : "must be a valid DNS zone name."
}
},
"Mappings" : {
"Region2S3WebsiteSuffix": {
"us-east-1" : { "Suffix": ".s3-website-us-east-1.amazonaws.com" }
}
},
"Resources" : {
"S3BucketForWebsiteContent" : {
"Type" : "AWS::S3::Bucket",
"Properties" : {
"AccessControl" : "PublicRead",
"WebsiteConfiguration" : {
"IndexDocument" : "index.html",
"ErrorDocument" : "error.html"
}
}
},
"WebsiteCDN" : {
"Type" : "AWS::CloudFront::Distribution",
"Properties" : {
"DistributionConfig" : {
"Comment" : "CDN for S3-backed website",
"Aliases" : [{ "Fn::Join" : [ "", [{"Ref" : "AWS::StackName"}, {"Ref" : "AWS::AccountId"}, ".", {"Ref" : "AWS::Region"}, ".", { "Ref" : "HostedZone" }]]}],
"Enabled" : "true",
"DefaultCacheBehavior" : {
"ForwardedValues" : { "QueryString" : "true" },
"TargetOriginId" : "only-origin",
"ViewerProtocolPolicy" : "allow-all"
},
"DefaultRootObject" : "index.html",
"Origins" : [
{ "CustomOriginConfig" :
{
"HTTPPort" : "80",
"HTTPSPort" : "443",
"OriginProtocolPolicy" : "http-only"
},
"DomainName" : { "Fn::Join" : ["", [{"Ref" : "S3BucketForWebsiteContent"},
{"Fn::FindInMap" : [ "Region2S3WebsiteSuffix", {"Ref" : "AWS::Region"}, "Suffix" ]}]]},
"Id" : "only-origin"
}]
}
}
},
"WebsiteDNSName" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"HostedZoneName" : { "Fn::Join" : [ "", [{ "Ref" : "HostedZone" }, "."]]},
"Comment" : "CNAME redirect custom name to CloudFront distribution",
"Name" : { "Fn::Join" : [ "", [{"Ref" : "AWS::StackName"}, {"Ref" : "AWS::AccountId"}, ".", {"Ref" : "AWS::Region"}, ".", { "Ref" : "HostedZone" }]]},
"Type" : "CNAME",
"TTL" : "900",
"ResourceRecords" : [{ "Fn::Join" : [ "", ["http://", {"Fn::GetAtt" : ["WebsiteCDN", "DomainName"]} ]]}]
}
}
},
"Outputs" : {
"WebsiteURL" : {
"Value" : {"Fn::Join" : [ "", ["http://", {"Ref" : "WebsiteDNSName"} ]] },
"Description" : "The URL of the newly created website"
},
"BucketName" : {
"Value" : { "Ref" : "S3BucketForWebsiteContent" },
"Description" : "Name of S3 bucket to hold website content"
}
}
}