我有以下 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
And
$ aws s3 cp /tmp/test s3://MYBUCKET/temp/prod/tests/
An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
如果删除条件,我就可以按预期复制文件。
我不明白为什么条件不起作用,因为据我所知,我发出的请求与条件的前缀匹配。
有谁知道为什么这不能按我的预期工作?