【问题标题】:Custom DNS for Cloudfront returns 403Cloudfront 的自定义 DNS 返回 403
【发布时间】:2021-04-21 18:44:47
【问题描述】:

我正在使用 Cloudformation 来部署资源。这包括 Cloudfront CDN 和 RecordSet。我希望它为自定义域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 控制台时,我唯一注意到的是备用域名 (CNAME) 为空:

当我用预期值test.example.com 填充它时,页面加载得很好。 我已尝试将 Aliases: test.example.com 添加到 Cloudfront DistributionConfig,但随后出现 RecordSet 循环错误。

如何在 Cloudformation 中同时拥有 CDN 和 RecordSet,并填充备用域名 (CNAME)?

云端:

  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

DNS:

  DNS:
    Type: AWS::Route53::RecordSetGroup
    Properties:
      HostedZoneId: <<id>>
      RecordSets:
        - Name: test.example.com
          Type: A
          AliasTarget:
            HostedZoneId: Z2FDTNDATAQYW2
            DNSName: !GetAtt
              - Distribution
              - DomainName

【问题讨论】:

  • 您需要在 CF 发行版中使用 Aliases。所以我会专注于“我得到一个循环错误”的问题。您能否准确说明您尝试了什么以及错误是什么。
  • @Marcin 当我将以下内容添加到 Cloudfront 资源时,我收到错误:Aliases: !Ref DNS。错误:Circular dependency between resources: [DNS, Distribution]

标签: amazon-cloudformation amazon-cloudfront


【解决方案1】:

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

Aliases:
  - test.example.com

我的错误是我之前引用了 DNS:

Aliases: !Ref DNS

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

【讨论】:

    猜你喜欢
    • 2018-01-26
    • 2016-07-27
    • 2017-10-31
    • 2021-03-31
    • 2014-07-07
    • 2011-03-08
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多