Skip to content

Public Images in S3

0

I'm uploading image to my new S3 Bucket but when I try to access image from public URL (obviously I have set No restrictions) I get this ERROR

<Error> <Code>AccessDenied</Code> <Message>Access Denied</Message> <RequestId>SQF920R06021JXAN</RequestId> <HostId>BG7wVwTNIHtNXSAo4WVgFUPoMPGKMxpwKJigHs+F/OkSyi3zij3915ElPmmm1PPtuFAND6pHUh3oVB7u0HTzDiRH0+4lzev3</HostId> </Error>

asked a year ago298 views

1 Answer
0

It looks like you're experiencing an "Access Denied" error when trying to access your S3 image via a public URL. Even though you mentioned setting "No restrictions," there are several specific settings that need to be configured correctly to make a single file publicly accessible in S3.

Here's what you need to check:

  1. Block Public Access settings:
  • Go to your S3 bucket and click on the "Permissions" tab
  • Under "Block public access," make sure the following settings are turned OFF:
  • "Block public access to buckets and objects granted through new public bucket or access point policies"
  • "Block public access to buckets and objects granted through any access control lists (ACLs)"
  • You might need to uncheck all four individual settings
  1. Make the specific object public using one of these methods:

Option A: Using ACLs (if ACLs are enabled):

  • Select the file in S3
  • Click "Actions" dropdown
  • Select "Make public using ACL"
  • Confirm the action

Option B: Using a bucket policy (recommended approach):

  • In the "Permissions" tab, go to "Bucket policy"
  • Add a policy that grants public read access only to your specific object:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForSingleObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/path/to/your/specific/file.jpg"
}
]
}
  • Replace "YOUR-BUCKET-NAME" and the file path with your actual bucket name and object path

After making these changes, try accessing the object URL again. Remember that any object made public will be accessible to anyone on the internet, so ensure the file doesn't contain sensitive information.
Sources
How do I make a single file in an S3 bucket publicly accessible? | AWS re:Post
How do I create a public URL for one file in S3? | AWS re:Post
Simple S3 Permissions Help | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.