Amazon cloudformation Cloudfront的自定义DNS返回403

Amazon cloudformation Cloudfront的自定义DNS返回403,amazon-cloudformation,amazon-cloudfront,Amazon Cloudformation,Amazon Cloudfront,我正在使用Cloudformation部署资源。这包括一个Cloudfront CDN和一个记录集。我希望它为自定义域test.example.com创建一个新的记录集,该记录集将指向我的Cloudfront CDN,它指向一个S3存储桶。成功部署后,出现以下错误: 403 ERROR The request could not be satisfied. Bad request. We can't connect to the server for this app or website at

我正在使用Cloudformation部署资源。这包括一个Cloudfront CDN和一个记录集。我希望它为自定义域
test.example.com
创建一个新的记录集,该记录集将指向我的Cloudfront CDN,它指向一个S3存储桶。成功部署后,出现以下错误:

403 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
使用Cloudfront域进行测试是成功的。当我检查AWS控制台时,唯一注意到的是备用域名(CNAMEs)为空:

当我用预期值
test.example.com
填充该页面时,页面加载很好。 我曾尝试将
别名:test.example.com
添加到Cloudfront
DistributionConfig
中,但随后记录集出现循环错误

我如何在Cloudformation中同时拥有CDN和记录集,并填充备用域名(CNAMEs)

云锋:

  Distribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        Origins:
          -
            # Use the Website as the origin
            DomainName: !GetAtt 'Website.DomainName'
            Id: !Ref Website
            S3OriginConfig:
              OriginAccessIdentity: !Join [ '', [ 'origin-access-identity/cloudfront/', !Ref CloudFrontOriginAccessIdentity] ]
        Enabled: true
        HttpVersion: http2
        DefaultRootObject: index.html
        CustomErrorResponses:
          - ErrorCode: 404
            ResponseCode: 200
            ResponsePagePath: /index.html
          - ErrorCode: 403
            ResponseCode: 200
            ResponsePagePath: /index.html
        DefaultCacheBehavior:
          AllowedMethods:
            - DELETE
            - GET
            - HEAD
            - OPTIONS
            - PATCH
            - POST
            - PUT
          DefaultTTL: 60
          ForwardedValues:
            QueryString: true
            Cookies:
              Forward: none
          # The origin id defined above
          TargetOriginId: !Ref Website
          ViewerProtocolPolicy: "redirect-to-https" # we want to force https
        # The certificate to use when using https
        ViewerCertificate:
          AcmCertificateArn: arn:aws:acm:us-east-1:<id>:certificate/<certId>
          MinimumProtocolVersion: TLSv1
          SslSupportMethod: sni-only
分发:
类型:AWS::CloudFront::Distribution
特性:
分配配置:
起源:
-
#使用该网站作为来源
域名:!GetAtt'Website.DomainName'
身份证:!参考网站
S3OriginConfig:
OriginAccessIdentity:!加入['',['源访问标识/cloudfront/',!Ref CloudFrontOriginAccessIdentity]]
已启用:true
HttpVersion:http2
DefaultRootObject:index.html
CustomErrorResponses:
-错误代码:404
响应代码:200
ResponsePagePath:/index.html
-错误代码:403
响应代码:200
ResponsePagePath:/index.html
DefaultCacheBehavior:
允许的方法:
-删除
-得到
-头
-选择权
-补丁
-职位
-放
默认TTL:60
转发值:
质询:对
曲奇饼:
转发:无
#上面定义的源id
TargetOriginId:!参考网站
ViewerProtocolPolicy:“重定向到https”#我们想强制https
#使用https时要使用的证书
查看者证书:
acm证书学习:arn:aws:acm:us-east-1::证书/
最小溶出度:TLSv1
SSL支持方法:仅限sni
域名系统:

DNS:
类型:AWS::Route53::RecordSetGroup
特性:
HostedZoneId:
记录集:
-名称:test.example.com
类型:A
别名目标:
HostedZoneId:z2fdtndaqyw2
DNSName:!格塔特
-分布
-域名

当我将以下内容添加到Cloudfront发行版时,它看起来是成功的:

Aliases:
  - test.example.com
我的错误是我以前引用过DNS:

Aliases: !Ref DNS

这是不正确的,并导致我的循环依赖性问题

您需要CF发行版中的
别名
。所以我会集中讨论“我得到一个循环错误”的问题。您能否确切说明您尝试了什么以及错误是什么。@Marcin当我将以下内容添加到Cloudfront资源时,我得到了错误:
别名:!参考DNS
。错误:
资源之间的循环依赖:[DNS,分发]
Aliases: !Ref DNS