How can I restrict access to an S3 website to Cloudfront

0 votes

I want to put a Cloudfront CDN in front of a S3 website bucket for a static website, and restrict read access of the bucket to the Cloudfront distribution. Pretty common, and documented by AWS and other sources. But for some reason I can’t get it to work.

And I’m not the first one to stumble upon this. (123). I’ve tried the solutions posted there, but again, no luck.

I also tried tweaking values in PublicAccessBlockConfiguration and AccessControl and tried uploading bucket content with aws s3 sync … --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers.

But I always end up with either public S3 content, or content being unavailable via Cloudfront as well.

Does anybody have an idea what else I could try?

Mar 22 in Others by Edureka
• 9,320 points
63 views

1 answer to this question.

0 votes
Make a CloudFront access identity for origin access (OAI)

1. Log in to CloudFront's management console.

2. Select the distribution that serves material from the S3 bucket to which access should be restricted from the list of distributions.

3. Select the Origins option from the drop-down menu.

4. Choose Edit and then select the S3 origin.

5. Select Yes to use OAI for S3 bucket access (bucket can restrict access to only CloudFront).

6. Choose an existing identity from the selection list or create a new OAI for Origin access identity.

7. Select Yes to update the bucket policy in the Bucket policy section.
Note: This step modifies your S3 origin's bucket policy to grant OAI access to the following buckets:
GetObject.

Select Save Changes from the drop-down menu.
answered Mar 24 by Edureka
• 9,320 points

Related Questions In Others

0 votes
1 answer
0 votes
0 answers

how can I deploy a test in pytest framework to airflow using DAG?

I have established an automative testing framework ...READ MORE

Oct 4, 2021 in Others by Yuan
• 120 points
26 views
0 votes
1 answer

How to maximize SEO of an internationalized website?

there is no single answer to SEO ...READ MORE

answered Feb 11 in Others by narikkadan
• 7,860 points
34 views
0 votes
1 answer
0 votes
0 answers

How to disable Amazon S3 raw endpoint access

Hosting  a static website on S3 : You ...READ MORE

Apr 10 in Others by Kichu
• 16,850 points
31 views
0 votes
0 answers
0 votes
1 answer

How can you create an object in JavaScript?

JavaScript supports Object concept very well. You can create ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
171 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 9,320 points
65 views
0 votes
1 answer

How to convert data from txt files to Excel files using python

Hi , there are few steps to ...READ MORE

answered Feb 16 in Others by Edureka
• 9,320 points
1,360 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP