AWS Builder Center
CloudFront 403? Don't Make Your S3 Bucket Public — Fix It Properly

CloudFront 403? Don't Make Your S3 Bucket Public — Fix It Properly

Getting a 403 Access Denied error when connecting Amazon CloudFront to a private S3 bucket? Making the bucket public isn't the solution. This hands-on guide shows how to configure CloudFront Origin Access Control, secure S3 permissions, identify five common causes of 403 errors, and troubleshoot your deployment without compromising security.

Introduction: The Temptation to Click "Allow Public Access"

Introduction: The Temptation to Click "Allow Public Access"
Imagine you've just deployed your first static website using Amazon S3 and CloudFront.
You've uploaded your files, created a CloudFront distribution, and opened the distribution URL in your browser.
Instead of your website, you see:
403 Forbidden — Access Denied
Your first instinct might be to open the S3 bucket permissions and disable Block Public Access.
After all, visitors need to access your website, right?
But here's the important distinction:
Your website can be publicly accessible without making its underlying S3 bucket public.
Understanding this difference is an important step toward designing secure AWS architectures.
In this article, we'll build a simple website using a private S3 bucket and CloudFront, then examine five common causes of 403 errors and how to troubleshoot them.

1. Understanding the Architecture

Our architecture is deliberately simple:
User → HTTPS → Amazon CloudFront → Origin Access Control → Private S3 Bucket
Each component has a specific responsibility.
Amazon S3: Stores our website files, including HTML, CSS, JavaScript and images.
Amazon CloudFront: Delivers those files to visitors through a global content delivery network (CDN).
Origin Access Control (OAC): Allows CloudFront to authenticate requests to our private S3 bucket.
Instead of allowing everyone on the internet to retrieve files directly from S3, we grant a specific CloudFront distribution permission to read them.
Visitors access the website through CloudFront.
The S3 bucket remains private.
For this example, we're creating a publicly viewable static website, not a website requiring user authentication.

2. Step One: Create a Private S3 Bucket

Open the AWS Management Console and navigate to Amazon S3.
Create a new bucket with a globally unique name, such as:
 your-unique-cloudfront-demo-2026 
Choose your preferred AWS Region.
For this tutorial:
  • Keep Block all public access enabled.
  • Keep Object Ownership set to Bucket owner enforced.
  • Leave S3 static website hosting disabled.
  • Use the default encryption settings unless your requirements specify otherwise.
Why leave static website hosting disabled?
Because this architecture uses CloudFront's regular S3 bucket origin with OAC, not the S3 website endpoint.
OAC is not supported for S3 origins configured using the website endpoint.

3. Step Two: Upload a Simple Website

Create a file named  index.html  on your computer.
Paste the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1">
<title>My AWS Website</title>
</head>
<body>
<h1>Hello, AWS Builders!</h1>
<p>My website is delivered through CloudFront.</p>
<p>My S3 bucket is private.</p>
</body>
</html>
Upload the file to the root of your S3 bucket.
At this point, the file exists in S3, but anonymous internet users should not be able to access it directly.
That's intentional.

4. Step Three: Create a CloudFront Distribution

Open the Amazon CloudFront console and create a distribution.
Configure the following:
Origin: Select your S3 bucket using its regular S3 endpoint, not its website endpoint.
Origin access: Choose Origin Access Control (OAC), creating a new control if necessary.
Signing behavior: Select Sign requests (recommended).
Viewer protocol policy: Choose Redirect HTTP to HTTPS.
Default root object: Enter  index.html .
For this simple static site, allow the GET and HEAD methods.
You can use the default CloudFront domain name for testing, so purchasing a custom domain isn't necessary.
CloudFront will assign a domain similar to:
 d123example.cloudfront.net 
Your actual distribution domain will be different.

5. Step Four: Give CloudFront Permission to Read from S3

This is the part that frequently causes confusion.
Creating a CloudFront distribution doesn't mean it automatically has permission to read every object in a private S3 bucket.
The bucket policy must authorize the CloudFront service to read objects through the intended distribution.
If the CloudFront console offers to generate or apply the bucket policy automatically, use that option.
Otherwise, the following is an example of the required policy structure:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCloudFrontReadOnly",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::YOUR_ACCOUNT_ID:distribution/YOUR_DISTRIBUTION_ID"
}
}
}
]
}
Replace the three placeholders with your actual bucket name, AWS account ID, and CloudFront distribution ID.
Add the policy under your S3 bucket's Permissions tab.
Notice something important about the policy.
We're not granting  s3:GetObject  permission to everyone.
We're allowing the CloudFront service to read objects when requests originate from our designated distribution.
This is a practical example of applying least-privilege permissions.

6. Step Five: Test Your Website

After the distribution finishes deploying and permissions are configured, open your CloudFront URL.
You should see:
Hello, AWS Builders!
Now try accessing the object through its direct S3 URL without AWS credentials.
Access should be denied.
That's the intended behavior:
  • Public visitors can retrieve the website through CloudFront.
  • Anonymous visitors cannot bypass CloudFront to access the private S3 objects directly.
You have separated public content delivery from direct origin access.

7. Five Common Causes of CloudFront 403 Errors

Now for the interesting part.
What if you've followed the steps but still receive an Access Denied error?
Here are five things I would investigate.

Cause 1: CloudFront Doesn't Have Permission

The first thing to check is your S3 bucket policy.
Confirm that:
  • The CloudFront service principal is correct.
  • The policy includes  s3:GetObject .
  • The bucket name matches your actual bucket.
  • The distribution ARN is correct.
  • The intended OAC is attached to the origin.
Avoid making the bucket public as a troubleshooting shortcut.
Fix the permissions instead.

Cause 2: You're Using the Wrong S3 Endpoint

S3 provides different endpoint types.
For this architecture, CloudFront needs the regular S3 bucket origin.
Do not select the S3 website endpoint.
The difference matters because an S3 website endpoint is treated as a custom origin and doesn't support OAC.
If you've selected the wrong endpoint, review your CloudFront origin settings.

Cause 3: You Forgot the Default Root Object

This is a surprisingly easy mistake.
Your browser requests:
 https://your-distribution.cloudfront.net/ 
But your file is named:
 index.html 
Without a configured default root object, CloudFront doesn't automatically know that requests for  /  should serve  index.html .
Open the distribution settings and set:
Default root object:  index.html 
Do not include a leading slash.
Also verify that the file exists at the expected location.

Cause 4: The Object Name or Path Is Wrong

S3 object names are case-sensitive.
 index.html  and  Index.html  are not the same file.
Similarly, an incorrectly configured origin path can cause CloudFront to request an object that doesn't exist.
One important detail is that a missing object in a private S3 bucket can sometimes result in a 403 response rather than a 404.
A 403 does not always mean the bucket policy is wrong.
Check the file name, object key, origin path, and requested URL.

Cause 5: You're Seeing a Cached Error or Another Access Restriction

CloudFront caches responses, including certain errors.
After correcting your configuration, you may need to invalidate an affected path or allow the error cache to expire.
You should also check for other restrictions that could block requests.
These may include explicit deny policies, AWS WAF rules, or additional permissions required when objects use SSE-KMS encryption.
Remember that CloudFront can return 403 responses for several different reasons.
The best troubleshooting approach is to identify which layer is denying access instead of immediately changing permissions.

8. A Simple Troubleshooting Checklist

When facing an unexpected 403, I would follow this order:
Check
What to verify
1. S3 object
Does the exact file exist?
2. CloudFront origin
Is it the regular S3 bucket endpoint?
3. OAC
Is request signing correctly configured?
4. Bucket policy
Does it allow the correct distribution to read objects?
5. Root object
Is  index.html  configured correctly?
6. Other restrictions
Are explicit denies, WAF rules, encryption permissions, or cached errors involved?
The order is intentional.
Start with the simplest configuration problems before investigating more advanced causes.
Also, avoid granting broad permissions solely to discover whether your website starts working.
A working application isn't necessarily a secure application.

9. What About Cost?

This design is relatively simple, but it isn't automatically free.
Potential charges include:
  • S3 storage and requests.
  • CloudFront data transfer and requests, depending on your selected pricing plan.
  • Optional logging, custom-domain services, or additional security features.
AWS also offers CloudFront pricing plans, including a Free plan for eligible use cases.
Before deploying, review the current pricing and configure billing alerts or AWS Budgets.
And if this is only a learning exercise, clean up your resources afterward.
For a standard CloudFront distribution, disable and delete it before deleting the S3 bucket, following the AWS cleanup guidance.
If you're using a CloudFront flat-rate plan, review its cancellation requirements first.

10. The Bigger Lesson: Security Shouldn't Be an Afterthought

There is an important architectural principle behind this relatively small exercise.
When something doesn't work, the quickest fix is not always the correct fix.
Making an S3 bucket public may appear to solve an access problem, but it changes the security boundaries of your application.
A better approach is to understand how the services communicate and grant only the permissions required.
In our example, CloudFront is the public entry point.
S3 is the private origin.
OAC provides authenticated origin access.
Each component has a clearly defined responsibility.
That separation makes the architecture easier to reason about and helps reduce unnecessary exposure.

Over to the AWS Community

I'm interested in how other builders approach this.
When you encounter a CloudFront 403 Access Denied error, what's the first thing you check?
A. The S3 bucket policy
B. Origin Access Control
C. The requested object or default root object
D. CloudFront configuration and caching
Or have you encountered a more unusual cause?
I'd particularly like to hear about the most difficult CloudFront or S3 permissions issue you've diagnosed.
What turned out to be the actual problem?
Share your experience in the comments. It might save another builder hours of troubleshooting.



Further Reading

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article