【发布时间】:2021-01-25 19:31:47
【问题描述】:
我有以下 s3 IAM 政策。它旨在允许我从存储桶中的 temp/prod/tests 位置复制文件或将文件放入存储桶中。
在策略中,我添加了 StringLike 条件,我希望在对象前缀包含 temp/prod/tests 时允许策略中的权限允许复制和放置。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"s3:ReplicateObject",
"s3:PutObject",
"s3:ListBucket",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:GetBucketLocation",
"s3:GetBucketAcl",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::MYBUCKET/temp/prod/tests/*",
"arn:aws:s3:::MYBUCKET"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"temp/prod/tests/*",
"temp/prod/tests/"
]
}
}
}
]
}
我的问题是该条件阻止我复制 temp/prod/tests/ 下的任何内容,或将任何新对象放入此存储桶中的此位置下方。
$ aws s3 cp --recursive s3://MYBUCKET/temp/prod/tests/ /tmp
download failed: s3://MYBUCKET/temp/prod/tests/testfiles/testfile to ../../../tmp/testfiles/testfile An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
和
$ aws s3 cp /tmp/test s3://MYBUCKET/temp/prod/tests/
An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
如果我删除条件,我可以按预期复制文件。
我不明白为什么条件不起作用,因为据我所知,我发出的请求与条件的前缀匹配。
有谁知道为什么这不符合我的预期?
【问题讨论】:
标签: amazon-web-services amazon-s3 amazon-iam