2016-11-20 105 views
0

我正在尝试为特定用户定义策略。 我在S3中有几个桶,但我想让用户访问其中的一些。 我创建了以下政策:Amazon s3用户策略

{ 
    "Version":"2012-10-17", 
    "Statement":[ 
    { 
    "Sid":"AddPerm", 
    "Effect":"Allow", 
    "Principal": "*", 
    "Action":["s3:GetObject", 
      "s3:ListBucket", 
      "s3:ListAllMyBuckets", 
      "s3:GetBucketLocation", 
      "s3:PutObject"], 
    "Resource":["arn:aws:s3:::examplebucket"] 
} 

,当我尝试添加的资源列表如下:

"Resource":["arn:aws:s3:::examplebucket1","arn:aws:s3:::examplebucket2"] 

我得到拒绝访问

,对我(我工作的唯一选择得到水桶名单)是:

"Resource": ["arn:aws:s3:::*"] 

什么问题呢?

+0

'阿尔恩:AWS:S3 ::: examplebucket1'是桶的资源标识符; 'arn:aws:s3 ::: examplebucket1/*'是桶内对象的通配符标识符。针对存储桶的权限!=对象的权限。试试这个改变? –

回答

0

一些亚马逊S3 API调用在 -level操作,而一些在对象 - 电平操作。因此,你需要像策略:

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Effect": "Allow", 
     "Action": ["s3:ListBucket"], 
     "Resource": ["arn:aws:s3:::test"] 
    }, 
    { 
     "Effect": "Allow", 
     "Action": [ 
     "s3:PutObject", 
     "s3:GetObject", 
     "s3:DeleteObject" 
     ], 
     "Resource": ["arn:aws:s3:::test/*"] 
    } 
    ] 
} 

参见:AWS安全博客 - Writing IAM Policies: How to Grant Access to an Amazon S3 Bucket

0

我发现,它的AWS限制。 没有选项可以获取桶的已过滤列表。 一旦你给了权限ListAllMyBuckets这样的:

{ 
    "Sid": "AllowUserToSeeBucketListInTheConsole", 
    "Action": ["s3:GetBucketLocation", "s3:ListAllMyBuckets"], 
    "Effect": "Allow", 
    "Resource": ["arn:aws:s3:::*"] 

}

你得到所有桶(包括您没有权限给它桶)的列表。

更多信息可以在这里找到:https://aws.amazon.com/blogs/security/writing-iam-policies-grant-access-to-user-specific-folders-in-an-amazon-s3-bucket/

几个解决方法可以在这里找到:Is there an S3 policy for limiting access to only see/access one bucket?

相关问题