How can I make a S3 bucket public (the amazon example policy doesn't work)?

后端 未结 8 475
庸人自扰
庸人自扰 2020-12-28 16:38

Amazon provides an example for Granting Permission to an Anonymous User as follows (see Example Cases for Amazon S3 Bucket Policies):

{
    \"Versio         


        
相关标签:
8条回答
  • 2020-12-28 17:10

    The following policy will make the entire bucket public :

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

    If you want a specific folder under that bucket to be public using Bucket policies , then you have to explicitly make that folder/prefix as public and then apply the bucket policy as follows :

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

    The above policy will allow public read to all of the objects under images , but you will not be able to access other objects inside the bucket.

    0 讨论(0)
  • 2020-12-28 17:12

    Bucket policies do not apply files with other owners. So although I've given write access to a third party, the ownership remains them, and my bucket policy will not apply to those objects.

    0 讨论(0)
提交回复
热议问题