【发布时间】:2013-12-06 20:20:31
【问题描述】:
我有一个桶,里面装满了大部分需要公开的内容。但是,只有一个经过身份验证的 IAM 用户才能访问一个文件夹(又名“前缀”)。
{
"Statement": [
{
"Sid": "AllowIAMUser",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::bucket/prefix1/prefix2/private/*",
"Principal": {
"AWS": [
"arn:aws:iam::123456789012:user/bobbydroptables"
]
}
},
{
"Sid": "AllowAccessToAllExceptPrivate",
"Action": [
"s3:GetObject",
"s3:GetObjectVersion"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::bucket/*",
"Condition": {
"StringNotLike": {
"s3:prefix": "prefix1/prefix2/private/"
}
},
"Principal": {
"AWS": [
"*"
]
}
}
]
}
当我尝试保存此策略时,我从 AWS 收到以下错误消息:
Conditions do not apply to combination of actions and resources in statement -
Condition "s3:prefix"
and action "s3:GetObject"
in statement "AllowAccessToAllExceptPrivate"
显然这个错误特别适用于第二个语句。 “s3:GetObject”动作不能使用“s3:prefix”条件吗?
是否可以获取公共存储桶的一部分并使其仅供经过身份验证的用户访问?
如果重要,此存储桶将只能通过 api 以只读方式访问。
这个问题类似于Amazon S3 bucket policy for public restrictions only,除了我试图通过不同的方法来解决这个问题。
【问题讨论】:
标签: amazon-web-services amazon-s3