aws config_error ai_generated true

The specified default root object is not valid. The object must be in the distribution's origin.

ID: aws/cloudfront-invalid-default-root-object

Also available as: JSON · Markdown · 中文
90%Fix Rate
86%Confidence
1Evidence
2024-08-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
cloudfront-2024 active
aws-cli/2.17.0 active
s3-2024 active

Root Cause

The CloudFront distribution's Default Root Object (e.g., index.html) does not exist in the S3 bucket or custom origin at the root path.

generic

中文

CloudFront 分发的默认根对象(例如 index.html)在 S3 存储桶或自定义源的根路径中不存在。

Official Documentation

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html

Workarounds

  1. 90% success Upload the default root object to the S3 bucket root: `aws s3 cp index.html s3://my-bucket/index.html` and ensure the bucket policy allows public read (if applicable).
    Upload the default root object to the S3 bucket root: `aws s3 cp index.html s3://my-bucket/index.html` and ensure the bucket policy allows public read (if applicable).
  2. 85% success If using a custom origin, place the file at the origin's root (e.g., /var/www/html/index.html for an EC2 web server).
    If using a custom origin, place the file at the origin's root (e.g., /var/www/html/index.html for an EC2 web server).

中文步骤

  1. 将默认根对象上传到 S3 存储桶根目录:`aws s3 cp index.html s3://my-bucket/index.html` 并确保存储桶策略允许公共读取(如果适用)。
  2. 如果使用自定义源,将文件放置在源根目录(例如 EC2 Web 服务器的 /var/www/html/index.html)。

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Setting the Default Root Object to a path with a leading slash (e.g., '/index.html') is invalid; CloudFront expects no leading slash.

  2. 90% fail

    Uploading the file to a subfolder instead of the bucket root won't work; the root object must be at the origin root.