MalformedPolicy
cloud
config_error
ai_generated
true
访问被拒:存储桶策略过大。存储桶策略的最大大小为 20 KB。
AccessDenied: The bucket policy is too large. The maximum size for a bucket policy is 20 KB.
ID: cloud/aws-s3-bucket-policy-too-large
90%修复率
85%置信度
1证据数
2023-04-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| AWS S3 API 2006-03-01 | active | — | — | — |
| AWS CLI 2.15 | active | — | — | — |
根因分析
存储桶策略 JSON 文档的总大小超过 AWS 的 20 KB 限制,通常由过多语句或长 ARN 导致。
English
The combined size of the bucket policy JSON document exceeds AWS's 20 KB limit, often due to many statements or long ARNs.
官方文档
https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html解决方案
-
使用 IAM 策略代替存储桶策略来管理用户/角色权限。将用户级别的语句移到 IAM,存储桶策略仅保留跨账户或服务范围的规则。
-
使用通配符和条件键合并多个语句。例如:将每个前缀的单独语句改为一个带 's3:prefix' 条件和多个 Resource 值的语句。
-
使用 S3 接入点及其策略来分担存储桶策略的权限。创建接入点并在其上附加策略。
无效尝试
常见但无效的做法:
-
99% 失败
Compressing the JSON or removing whitespace saves negligible space while breaking readability.
-
70% 失败
Splitting policy across multiple buckets requires restructuring app logic and often isn't feasible.
-
85% 失败
Using a different IAM role per statement on the same policy doesn't reduce size; it may increase it.