# 指定的默认根对象无效。该对象必须位于分发的源中。

- **ID:** `aws/cloudfront-invalid-default-root-object`
- **领域:** aws
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| cloudfront-2024 | active | — | — |
| aws-cli/2.17.0 | active | — | — |
| s3-2024 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Setting the Default Root Object to a path with a leading slash (e.g., '/index.html') is invalid; CloudFront expects no leading slash. (80% 失败率)
- **** — Uploading the file to a subfolder instead of the bucket root won't work; the root object must be at the origin root. (90% 失败率)
