gpt4 book ai didi

c# - AWS S3 ListMultipartUploads : access denied

转载 作者:可可西里 更新时间:2023-11-01 08:49:58 28 4
gpt4 key购买 nike

我关注了this blog为了使用 Web Identity Federation 设置我的 AWS IAM 和 S3 帐户。我能够很好地验证和接收 session 凭据和 token 。我还可以下载和上传对象。但是,我得到:

access denied

在以下 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。我做错了什么?

最佳答案

我在你的前缀语句中看到一个错误,

需要是一个数组,

"s3:prefix": ["${myidentityprovider:userId}/*"]

{
"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}/*"]
}
}
}
]}

关于c# - AWS S3 ListMultipartUploads : access denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45183481/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com