Skip to content

How do I obtain a public access link for my S3 bucket resource?

0

Hey, I have this index.html object in my S3 bucket and I'm wondering how to get a public access URL. I thought I had everything setup correctly, but I keep getting an access denied error whenever I click on the object URL.

Enter image description here

Enter image description here

Enter image description here

Enter image description here

I would appreciate step by step instructions for resolving the error, thank you.

asked a year ago2K views
2 Answers
0

I think what you are missing is the bucket policy (Something like below)

`{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::Bucket-Name/*"
            ]
        }
    ]
}`
answered a year ago
EXPERT
reviewed a year ago
  • Or Set the Everyone ACL to be READ on objects

0

To obtain a public access link for your S3 bucket resource and resolve the access denied error, you'll need to follow these steps:

  1. Disable Block Public Access settings for your bucket:

    • Go to your S3 bucket in the AWS Management Console
    • Click on the "Permissions" tab
    • Scroll down to "Block public access (bucket settings)"
    • Click "Edit" and uncheck all four options
    • Save changes
  2. Update your bucket policy to allow public read access:

    • In the same "Permissions" tab, scroll to "Bucket policy"
    • Click "Edit" and add a policy that grants public read access to your objects
  3. Ensure the object itself allows public read access:

    • Go to the "Objects" tab in your bucket
    • Select your index.html file
    • Click "Actions" and choose "Make public using ACL"
  4. Double-check your bucket is configured for static website hosting:

    • Go to the "Properties" tab of your bucket
    • Scroll down to "Static website hosting"
    • Ensure it's enabled and properly configured with your index document

After completing these steps, you should be able to access your index.html file using the S3 website endpoint URL provided in the "Static website hosting" section.

Please note that making your S3 bucket public comes with security implications. Only do this if you intend for the content to be publicly accessible. For more secure options, consider using Amazon CloudFront with your S3 bucket or implementing more granular access controls.

Remember, by default, new S3 buckets and objects are set to block public access for security reasons. You're explicitly overriding these safeguards, so make sure this aligns with your intended use case.
Sources
Use your domain for a static website in an Amazon S3 bucket - Amazon Route 53
Amazon S3 Block Public Access - AWS
Access control in Amazon S3 - Amazon Simple Storage Service

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.