- Newest
- Most votes
- Most comments
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:
- 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
- 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
