question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storage.put should set ACL public-read for public files

See original GitHub issue

public files should be put with ACL of public-read

Inside the Storage.put

    const params: any = {
      Bucket: bucket,
      Key: final_key,
      Body: file,
      ContentType: type
    };

if (opt.level === "public") {
       params["Acl"] = "public-read";
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:22
  • Comments:23

github_iconTop GitHub Comments

11reactions
asmajlovicmarscommented, Mar 28, 2020

“Bucket” : {“Ref” : “bucketName”},

Slightly modified to include the env, etc, but this works perfect for me. Thank you @XC3S

"S3BucketPolicy": {
  "Type": "AWS::S3::BucketPolicy",
  "Properties": {
    "Bucket": {
      "Fn::Join": [
        "",
        [
          { "Ref": "bucketName" },
          {
            "Fn::Select": [
              3,
              {
                "Fn::Split": [
                  "-",
                  {
                    "Ref": "AWS::StackName"
                  }
                ]
              }
            ]
          },
          "-",
          {
            "Ref": "env"
          }
        ]
      ]
    },
    "PolicyDocument": {
      "Statement": [
        {
          "Sid": "PublidReadGetObject",
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Principal": "*",
          "Resource": {
            "Fn::Join": [
              "",
              [
                "arn:aws:s3:::",
                { "Ref": "bucketName" },
                {
                  "Fn::Select": [
                    3,
                    {
                      "Fn::Split": [
                        "-",
                        {
                          "Ref": "AWS::StackName"
                        }
                      ]
                    }
                  ]
                },
                "-",
                {
                  "Ref": "env"
                },
                "/*"
              ]
            ]
          }
        }
      ]
    }
  }
},
9reactions
RobertBrewitzcommented, Sep 16, 2018

Thanks @hutch120 for the tip!

I solved it by adding a bucket policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublidReadGetObject",
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Principal": "*",
            "Resource": "arn:aws:s3:::<bucketName>/public/*"
        }
    ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring ACLs - Amazon Simple Storage Service
This section explains how to manage access permissions for S3 buckets and objects using access control lists (ACLs). You can add grants to...
Read more >
Upload files to AWS S3 with public read ACL using AWS CLI ...
Upload files to AWS S3 with public read ACL using AWS CLI or Boto ... In some cases, you might need to store...
Read more >
Object Storage default permission | Linode Questions
Is there a command I can set every file's Acl to public after upload them? ... all objects put into it in the...
Read more >
Set ACL and Policy on S3 storage with aws cli - Gcore
Here is an example of setting a public acl (--acl public-read --) on a specific object (cat.jpg) ... aws s3api put-bucket-policy --policy file://policy.json ......
Read more >
Access control lists (ACLs) | Cloud Storage
The maximum number of ACL entries you can create for a bucket or object is 100. ... When specifying ACLs in Cloud Storage,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found