我有以下桶结构
--- MyBucket.Secure
------Database
---------App1
---------App2
我需要更新我的IAM角色,只允许 MyBucket.Secure/Database/App1 上的get / list。
我的情况类似于限制用户文件夹的AWS文档: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html#iam-policy-example-s3-home-directory
阅读完指南后,我提出了以下政策,试图满足我的要求:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1408970346000",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::*"
]
},
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::MyBucket.Secure",
"Condition": {"StringLike": {"s3:prefix": [
"",
"Database/",
"Database/App1/*"
]}}
},
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::MyBucket.Secure/Database/App1",
"arn:aws:s3:::MyBucket.Secure/Database/App1/*"
]
}
]
}
当我使用上述策略时,我收到以下错误: 调用HeadObject操作时发生客户端错误(403):禁止
任何想法我应该改变什么才能实现这一目标?
答案 0 :(得分:0)
在发布如下命令时,您的政策对我非常有用:
aws s3 ls s3://MyBucket.Secure/Database/App1/
(当然,我用自己的水桶来测试它。)
然而:
""
部分删除空字符串(s3:prefix
),否则用户也可以列出存储桶的根目录s3:List*
- 不需要