2013-08-04 58 views
5

您對理解S3 IAM策略和指令有困難嗎?無法將自己的頭圍繞在他們的文檔中?我做到了。Amazon S3針對IAM訪問的存儲區和文件夾策略?

我有一種情況,我必須從一個特定的文件夾中鎖定幾個IAM用戶,除了一個以外,它們的大部分解決方案和示例解決方案都像泥漿一樣清晰。網上淘並沒有找到什麼,我一直在尋找我來到一個資源 (http://blogs.aws.amazon.com/security/post/Tx1P2T3LFXXCNB5/Writing-IAM-policies-Grant-access-to-user-specific-folders-in-an-Amazon-S3-bucke)這是明確的,實際上有幫助的,但它確實需要一些修改,並且結果是你看到下面的政策....之後

它所做的是允許用戶訪問存儲桶中的特定文件夾,但DENIES可以訪問同一存儲桶中的任何其他列出的文件夾。請注意,你無法阻止他們查看文件夾的內容,也不會阻止他們看到有其他存儲桶,這是無法幫助的。但是,他們無法訪問您選擇的存儲桶/文件夾。

回答

7
{ 
"Version":"2012-10-17", 
"Statement": [ 
    { 
    "Sid": "AllowUserToSeeBucketListInTheConsole", 
    "Action": ["s3:ListAllMyBuckets", "s3:GetBucketLocation"], 
    "Effect": "Allow", 
    "Resource": ["arn:aws:s3:::*"] 
    }, 
    { 
    "Sid": "AllowRootAndHomeListingOfCompanyBucket", 
    "Action": ["s3:ListBucket"], 
    "Effect": "Allow", 
    "Resource": ["arn:aws:s3:::yourbucketname"], 
    "Condition":{"StringEquals":{"s3:prefix":["","yourfoldername/"],"s3:delimiter":["/"]}} 
    }, 
    { 
    "Sid": "AllowListingOfUserFolder", 
    "Action": ["s3:ListBucket"], 
    "Effect": "Allow", 
    "Resource": ["arn:aws:s3:::yourbucketname"], 
    "Condition":{"StringLike":{"s3:prefix":["yourfoldername/*"]}} 
    }, 
    { 
    "Sid": "AllowAllS3ActionsInUserFolder", 
    "Effect": "Allow", 
    "Action": ["s3:GetObject"], 
    "Resource": ["arn:aws:s3:::yourbucketname/yourfoldername/*"] 
    }, 
{ 
     "Action": [ 
     "s3:*" 
     ], 
     "Sid": "Stmt1375581921000", 
     "Resource": [ 
"arn:aws:s3:::yourbucketname/anotherfolder1/*", 
"arn:aws:s3:::yourbucketname/anotherfolder2/*", 
"arn:aws:s3:::yourbucketname/anotherfolder3/*", 
"arn:aws:s3:::yourbucketname/anotherfolder4/*" 
     ], 
     "Effect": "Deny" 
    } 
] 
} 
+1

你也應該能夠通過** ** NotResource否認 - ' 「NotResource」: 「」 阿爾恩:AWS:S3 ::: yourbucketname/yourfoldername/*」]' - 而不是列表所有例外 – drzaus

+1

調試策略(或至少測試它們)的一個好工具是IAM策略模擬器https://policysim.aws.amazon.com/home/index.jsp – drzaus

相關問題