为了使用 Web Identity Federation 设置我的 AWS IAM 和 S3 帐户,我已关注此博客。我能够很好地验证和接收会话凭据和令牌。我还可以下载和上传对象。但是,我得到:
拒绝访问
在以下 ListMultipartUploads 请求中:
var request = new ListMultipartUploadsRequest()
{
BucketName = bucketName,
Prefix = $"{UserId}/"
};
var response = await s3Client.ListMultipartUploadsAsync(request);
附加到我的 IAM 角色的访问策略是:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::mybucket/${myidentityprovider:userId}/*"
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:ListBucketMultipartUploads"
],
"Resource": [
"arn:aws:s3:::mybucket"
],
"Condition": {
"StringLike": {
"s3:prefix": "${myidentityprovider:userId}/"
}
}
}
]
}
如您所见,我拥有“s3:ListBucketMultipartUploads”权限,因此用户应该能够在他们的存储桶上执行 ListMultiPartUploads。我究竟做错了什么?