You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用YAML配置AWS CloudFront/S3时遇Indexdocument属性不支持错误

资源状态资源类型逻辑资源ID资源状态原因
UPDATE_FAILEDAWS::S3::BucketMyWebsiteEncountered unsupported property Indexdocument
UPDATE_ROLLBACK_IN_PROGRESSAWS::CloudFormation::Stackcloud-resume-challenge以下资源更新失败:[MyWebsite]。
UPDATE_COMPLETEAWS::S3::BucketMyWebsite-
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESSAWS::CloudFormation::Stackcloud-resume-challenge-
UPDATE_ROLLBACK_COMPLETEAWS::CloudFormation::Stackcloud-resume-challenge-

错误信息:Failed to create/update the stack: cloud-resume-challenge, Waiter StackUpdateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "UPDATE_ROLLBACK_COMPLETE" at least once


解决方案

1. 修复S3 Bucket核心错误

错误根源是三个格式问题:

  • WebsiteConfiguration下的Indexdocument拼写错误,需改为**IndexDocument**(D大写),CloudFormation对属性名大小写严格敏感
  • IndexDocument的正确格式是嵌套Suffix字段,不能直接赋值index.html
  • AccessControl的Public Read需改为PublicRead(无空格),否则会触发格式校验失败

修正后的S3 Bucket配置:

MyWebsite:
  Type: AWS::S3::Bucket
  Properties:
    AccessControl: PublicRead
    WebsiteConfiguration:
      IndexDocument:
        Suffix: index.html
    BucketName: mcderkaderkas-first-website

2. 优化CloudFront配置(可选)

为了配置更规范,建议调整以下几点:

  • Enabled字段使用布尔值true而非字符串"true"
  • TargetOriginId和Origin的Id改用简洁标识(如MyS3WebsiteOrigin),避免冗长URL
  • Origin的DomainName去掉http://前缀,符合CloudFront源配置规范

修正后的CloudFront配置:

MyDistribution:
  Type: AWS::CloudFront::Distribution
  Properties:
    DistributionConfig:
      DefaultCacheBehavior:
        ViewProtocolPolicy: allow-all
        TargetOriginId: MyS3WebsiteOrigin
        DefaultTTL: 0
        MinTTL: 0
        MaxTTL: 0
        ForwardedValues:
          QueryString: false
      Origins:
        - DomainName: mcderkaderkas-first-website.s3-website-us-east-1.amazonaws.com
          Id: MyS3WebsiteOrigin
          CustomOriginConfig:
            OriginProtocolPolicy: match-viewer
      Enabled: true
      DefaultRootObject: index.html

3. 完整修正后的YAML文件

Resources:
  MyWebsite:
    Type: AWS::S3::Bucket
    Properties:
      AccessControl: PublicRead
      WebsiteConfiguration:
        IndexDocument:
          Suffix: index.html
      BucketName: mcderkaderkas-first-website

  MyDistribution:
    Type: AWS::CloudFront::Distribution
    Properties:
      DistributionConfig:
        DefaultCacheBehavior:
          ViewProtocolPolicy: allow-all
          TargetOriginId: MyS3WebsiteOrigin
          DefaultTTL: 0
          MinTTL: 0
          MaxTTL: 0
          ForwardedValues:
            QueryString: false
        Origins:
          - DomainName: mcderkaderkas-first-website.s3-website-us-east-1.amazonaws.com
            Id: MyS3WebsiteOrigin
            CustomOriginConfig:
              OriginProtocolPolicy: match-viewer
        Enabled: true
        DefaultRootObject: index.html

4. 重新部署验证

  1. 登录AWS控制台进入CloudFormation服务
  2. 选择目标栈,点击更新
  3. 上传修正后的YAML文件,按提示完成更新
  4. 等待栈状态变为UPDATE_COMPLETE,即可验证S3网站和CloudFront分发功能

内容的提问来源于stack exchange,提问作者Travis Salmon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 22:45:45