amazon-web-services - S3 列出存储桶的所有子文件夹会产生 AccessDenied ,即使存储桶是公共的
问题描述
考虑 S3 中的以下策略:
{
"Version": "2012-10-17",
"Id": "AxelPolly12424242",
"Statement": [
{
"Sid": "Stmt242554354",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:ListBucket"],
"Resource": "arn:aws:s3:::mycoolbucketname/*",
"Condition":{"StringEquals":{"s3:prefix":["","examples"]}}
}
]
}
当我尝试点击我的存储桶名称时 https://mycoolbucketname.s3-us-east-2.amazonaws.com/examples
:
我们得到:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>KJLFSDHJJKGDFJKLGJDFKLGJLDF</RequestId>
<HostId>GLKSFDNGJKLFDJGKLDFJGKLFDJGFDGEOT89GJROIGIKDSFSDJSD</HostId>
</Error>
Block public access (bucket settings)
当我们在 Permissions 选项卡下也取消选中时,此策略有什么问题以及如何列出存储桶的所有子文件夹
。
解决方案
s3:prefix适用于存储桶资源,而不是对象。所以而不是:
"Resource": "arn:aws:s3:::mycoolbucketname/*",
你应该有:
"Resource": "arn:aws:s3:::mycoolbucketname",
推荐阅读
- gradle - gradle构建成功后,运行spring boot应用程序时找不到类
- mysql - 使用 Pandas 通过 SSH 隧道在 AWS 上查询我的数据库
- android - 为什么我的 Gradle 在我的 Unity Android 版本上失败?
- java - 为什么 Java Stack 有搜索方法?
- c++ - 我如何在 C++ 中使用“stdafx.h”?
- python-3.x - Tkinter - 新窗口中的画布和图像调整为新窗口分辨率
- python - AES 加密问题(特别是使用 CryptoSwift 加密和使用 PyCryptodome 解密)
- python - 将嵌套模型序列化为 Django 中的键控 JSON 对象
- java - 在空查询结果后获取列名
- c++ - How to find n%(k*k) without integer overflow?