简体   繁体   English

允许用户访问S3存储桶中的一个目录

[英]Allow user access to one directory in a S3 Bucket

I searched through existing questions and couldnt find an answer. 我搜索了现有问题,找不到答案。

I want to restrict access to one directory S3 bucket to some user. 我想限制某些用户对一个目录S3存储桶的访问。 For example, I have the directory my-bucket/test/123. 例如,我的目录为my-bucket / test / 123。 I put a few images to this directory. 我在此目录中放置了一些图像。 Other users should not have access to this directory. 其他用户不应具有对此目录的访问权限。 Then I created Bucket policy: 然后我创建了存储桶策略:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "AddPerm",
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::123456789000:user/some-user"
        },
        "Action": "s3:*",
        "Resource": "arn:aws:s3:::my-bucket/test/123/*"
    }
]
}

But when I tried to open file in browser, I recieved "Access Denied" message. 但是,当我尝试在浏览器中打开文件时,收到“访问被拒绝”消息。

I tried to use Deny effect and NotPrincipal . 我试图使用Deny effect和NotPrincipal In this case, the files are available to other users. 在这种情况下,其他用户可以使用这些文件。 Please help! 请帮忙!

You also need bucket listing permissions on the root prefix (folder) as described in this AWS doc Writing IAM Policies: Grant Access to User-Specific Folders in an Amazon S3 Bucket : 您还需要按照本AWS文档编写IAM策略:授予对Amazon S3存储桶中用户特定文件夹的访问权限中所述的对根前缀(文件夹)的存储桶列表权限:

Although David should have access to only his home folder, he requires additional permissions so that he can navigate to his folder in the Amazon S3 console. 尽管David只能访问其主文件夹,但他需要其他权限,以便他可以导航到Amazon S3控制台中的文件夹。 David needs permission to list objects at the root level of the my-company bucket and in the home/ folder. David需要获得权限才能在my-company存储桶的根级别和home /文件夹中列出对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM