# botocore异常：调用PutObject操作时发生访问被拒绝错误。

- **ID:** `llm/llamaindex-index-persistence-s3`
- **领域:** llm
- **类别:** auth_error
- **错误码:** `AccessDenied`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

当LlamaIndex尝试将索引数据持久化到云存储时，IAM权限不足以访问S3存储桶。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| llama-index 0.10.0 | active | — | — |
| llama-index 0.10.1 | active | — | — |
| boto3 1.34.0 | active | — | — |

## 解决方案

1. ```
   Update IAM policy to include s3:PutObject and s3:PutObjectAcl permissions for the specific bucket: {"Effect": "Allow", "Action": ["s3:PutObject"], "Resource": "arn:aws:s3:::your-bucket/*"}
   ```
2. ```
   Switch to local persistence: storage_context.persist(persist_dir='./storage') instead of S3
   ```

## 无效尝试

- **Setting AWS region to us-east-1 in boto3 config** — Region mismatch doesn't cause AccessDenied; it's a permission issue, not location. (95% 失败率)
- **Adding public access to S3 bucket** — Public access violates security best practices and doesn't address missing IAM policy. (85% 失败率)
