Skip to content
Advertisement

S3 Object upload to a private bucket using a pre-signed URL result in Access denied

I’m learning AWS and with my limited knowledge of AWS, am I right in saying that If I make pre-signed URLS to Upload and Download from a bucket – which is set to block all public access it should work? I take all my authentication and checks through API gateway, so if a user is able to hit the endpoint that returns a pre-signed URL to upload/download, then they are allowed to do so.

If I’m correct then I am confused to why I’m getting an Access denied error when I try to upload an image to my bucket (which blocks public access) via a pre-signed URL – it works perfectly when the bucket is set to public?

My Lambda function that creates a pre-signed URL:

JavaScript

My python code that get’s pre-signed URL and uses it to upload objects:

JavaScript

My policy for my lambda function:

JavaScript

Advertisement

Answer

It’s likely that your bucket has Block all public access turned on. Therefore, you cannot set the ACL of the object to public-read. The solution is that you can either turn off the Block all public access or change public-read to private.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement