Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security, Veeam & DevOps

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form

Serve Private S3 Bucket Contents Via CloudFront

Posted on 26/05/202216/08/2026 Dickson Victor By Dickson Victor No Comments on Serve Private S3 Bucket Contents Via CloudFront
  1. Home
  2. AWS/Azure/OpenShift
  3. Serve Private S3 Bucket Contents Via CloudFront
CloudFrontAWS

Amazon CloudFront is a content delivery network(CDN) operated by Amazon Web Services. Content delivery networks provide a globally-distributed network of proxy servers that cache content, such as web videos or other bulky media, more locally to consumers, thus improving access speed for downloading the content. In this article, you will learn how to Serve Private S3 Bucket Contents Via CloudFront. Amazon S3 or Simple Storage Service is a service offered by Amazon Web Services that provides object storage through a web service interface.

When you set up an Amazon S3 bucket as the origin of an Amazon CloudFront distribution, you give everyone permission to read the files in the bucket (public access). This allows anyone to access your files through CloudFront. Please see How to sync S3 Bucket with an EC2 instance, and how to delete AWS S3 Bucket and Objects via AWS CLI from Linux.

Please follow along to learn about CloudFront origin access identities, which address the need to secure and restrict public access to S3 buckets behind a CloudFront distribution.

Kindly refer to these related guides: How to add an EBS volume to AWS EC2 via the AWS Console and CLI, how to integrate AWS CodeBuild and AWS CodeCommit to SonarCloud, and how to deploy a React Application to AWS S3.

What is Amazon CloudFront origin access identity (OAI)?

Amazon CloudFront OAI is a simple function of CloudFront distribution that you can enable when you select S3 buckets as the origin. If you don’t use an OAI, the S3 bucket must allow public access.

image-52

OAI prevents users from viewing your S3 bucket contents through its URL, Your users can only use the URL of your CloudFront distribution. In this hands-on exercise, you will access private S3 bucket content via a CloudFront distribution.

Serve Private S3 Bucket Contents Via CloudFront

In order to achieve this goal, kindly follow the steps below and start off by creating an S3 bucket!

Please see how to redirect requests for your bucket’s website endpoint to another bucket or domain. How to sync S3 Bucket with an EC2 instance(Opens in a new browser tab), and how to grant public access to S3 Bucket using Policy. Also, see how to enable Amazon S3 default bucket encryption using S3 Console.

Step 1. Create S3 Bucket

From the AWS Management Console page, select the S3 service. Use the Create Bucket wizard to create a bucket with the following details:

Once the bucket is created, you will be taken to the Buckets dashboard. Click on the bucket name to view the details, and upload files and folders.

image-53
Click the “Add files” to upload a file

Step 2. Upload Object to Bucket

Once the bucket is open to view its contents, click the Upload button to add files/folders. Click the Add Files button, and upload the Sample.html. Or (or any file from your local computer) provided at the bottom of the current page.

Note that the Bucket has not allowed public access, therefore, the Sample.html file cannot be accessed via its object URL.
image-54
This figure above shows how to copy the S3 object URL.

The figure below shows AccessDenied an error while trying to access the file via its S3 object URL

image-55

The figure below shows that the individual object (Sample.html) has no public access.

image-56

Step 3. Create CloudFront Distribution

Select the CloudFront service from the Services menu at the top left corner of your AWS console. Start the Create Distribution wizard.

Under the Web delivery method, click the Get Started button, and use the following details to create a distribution:

cloudfrontValues
In the configuration table above, the Grant Read Permission on Bucket says that “Yes, update access bucket policy automatically to allows the Origin Access Identity user access to the bucket content.” Origin Access Identity user represents the CloudFront service. The policy is a JSON file that defines the access permissions to the bucket object.

Serve Private S3 Bucket Contents Via CloudFront

Leave the defaults for the rest of the options. It may take up to 10 minutes for the CloudFront Distribution to create. Upon successfully creating the CloudFront distribution, the S3 bucket access policy will also get updated automatically, as shown below.

image-57
The figure above shows the updated S3 access policy. 

Once your CloudFront distribution is created, and the status shows as Deployed, copy its Domain Name and append /Sample.html before pasting it into a new browser.

For the initial few attempts, your xxxx://dgf7z6g067r6d.cloudfront.net/Sample.html may redirect to xxxx://my-014421265158-bucket.s3.us-east-2.amazonaws.com/Sample.html, which is why you may still see an AccessDenied error.

Note: Remember, as soon as your CloudFront distribution is Deployed. It attaches to S3 and starts caching the S3 private pages. Once the caching is complete, the CloudFront domain name URL will stop redirecting to the S3 object URL.

CloudFront may take 10-30 minutes (or more) to cache the S3 page, and you will be able to view the webpage.

I hope you found this blog post helpful on How to Serve Private S3 Bucket Contents Via CloudFront. Please let me know in the comment session if you have any questions.

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
AWS/Azure/OpenShift, Network | Monitoring, Storage Tags:AWS, AWS s3, Website

Post navigation

Previous Post: DbxSvc Process: How to Fix “Cannot Start Proctored Exam”
Next Post: How to deploy WordPress on Azure App Service

Related Posts

  • install WSL on Windows
    How to install WSL on Windows Network | Monitoring
  • Featured Image 1
    System Drive Conversion: MBR to GPT on Windows 10 Storage
  • tape cleaning e1778595685861
    How to perform Tape Drive Cleaning in Practice Network | Monitoring
  • Repository Path in Veeam Scale Out Backup Repository e1779138897770
    Fix broken Repository Path in Veeam Scale-Out Backup Repository Backup
  • requestedlogon
    Error 1385: The user has not been granted the requested logon type at this time Network | Monitoring
  • feature functionapp
    Deploy a function app from Visual Studio to Azure Platform AWS/Azure/OpenShift

More Related Articles

insufficientaccessright 1 Azure AD Connect Permission issue: Error 8344 insufficient access rights to perform the operation AWS/Azure/OpenShift
install WSL on Windows How to install WSL on Windows Network | Monitoring
Watchguard Firewall 180504 100511 WatchGuard Log and Report Server Installation in a VM Network | Monitoring
How to download install and use Kitty SSH Client on Windows Video on how to Download and Use KiTTY SSH Client on Windows Network | Monitoring
Banner App GW 1 e1780480289732 Azure Application Gateway: Practical Configuration Guide AWS/Azure/OpenShift
k8 cluster How to build and deploy a Docker Image with Kubernetes Cluster Network | Monitoring

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

vexpert-badge-stars-5

Virtual Background

VEEAMLEGEND

Categories

Top 30 Sysadmin blog

veeaam100

Veeam Vanguard

  • Configure Data Deduplication on Windows Server
    Video on how to Configure Data Deduplication on Windows Server Windows Server
  • Fix error Microsoft Outlook cannot sign or encrypt this message when sending email.
    How to fix error “Microsoft Outlook cannot sign or encrypt this message” when sending email? Network | Monitoring
  • unnamed
    Remove Xbox from automatic startup: How to enable and disable automatic startup in Windows 11 Windows
  • windows server
    How to backup and restore a Windows DHCP Server via the DHCP Manager and PowerShell Windows Server
  • VBR upgrade to 12.2.3
    Upgrade Veeam Backup and Replication v12.3.x to 12.3.2 Backup
  • Featured image GettingWinReady
    Fix “Getting Windows Ready” Don’t turn off your computer stuck on Windows Windows
  • Chocolatey Packages
    Create Chocolatey Package: Upgrade Software with Chocolatey Scripts
  • mgithub
    How to use Command-Line on Git Bash and GitHub Desktop to PUSH local code to GitHub Version Control System

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,745 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Contact
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon
  • Bsky

Tags

Active Directory Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2026 TechDirectArchive

Loading Comments...

You must be logged in to post a comment.