Goodnews Azonubi
Backend/DevOps Engineer
3 min read
In this article, we’ll explore how to securely host a static website on a private Amazon S3 bucket using Amazon CloudFront with Origin Access Control (OAC). By following these steps, you can ensure that your website content is accessible only through authorized channels while benefiting from the performance and scalability of CloudFront.
To follow through with this article you need to meet the following requirements
Amazon Simple Storage Service (Amazon S3) is an object storage service used to store and retrieve any type data i.e text files, video files etc.
Amazon CloudFront is an Amazon web service that speeds up the distribution of your static and dynamic web contents securely using a content delivery network (CDN). CloudFront ensures your web contents are accessible globally by caching them in edge locations.
Create bucket and enter a unique bucket nameCreate bucket Leave other settings as default. By default your bucket is set to private
Upload your static website files to the S3 bucket.
This is all we are doing here for now
Go to the CloudFront service in the AWS Management Console.
Click Create a CloudFront distribution
Choose your s3 bucket name from the origin domain pop up.
You can choose to enable WAF which adds another layer of security to incoming traffic going to your CloudFront distribution
But since this is a temporal deployment you can go with the second option
Create distributionCopy Policy generated by CloudFront OAC
Let’s go back to our S3 bucket permission to paste our generated policy
Paste policy and save changes
Testing your setup
Go back to your CloudFront to copy your Distribution domain name
Paste on your browser
In conclusion, by following the steps outlined in this guide, you’ve successfully set up a secure and efficient hosting environment for your static website using Amazon S3, CloudFront, and Origin Access Control (OAC). Your website content is now accessible only through authorized channels, ensuring both security and scalability.
That’s all for now, I hope you found this helpful 🙂
Let’s connect on LinkedIn