2016-11-20 133 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?