Hosting a Static Website On S3 bucket With CloudFront.

Overview

In this article, you will learn how to deploy a simple website using HTML, CSS, and JavaScript using Amazon CloudFront and S3.

Amazon Simple Storage Service (S3) allows you to host static websites by providing object level storag…


This content originally appeared on DEV Community and was authored by Stephanie Albert

Image description

Overview

In this article, you will learn how to deploy a simple website using HTML, CSS, and JavaScript using Amazon CloudFront and S3.

Amazon Simple Storage Service (S3) allows you to host static websites by providing object level storage. It stores and retrives data as objects iwithin buckets, making it perfect for static website hosting.

Amazon CLoudFront is a Content Delivery Network (CDN) service which utilizes a network of edge locations to cache copies of your website content closer to users, reducing latency and ensuring faster delivery.

Step 1: Log in to AWS and Access S3

Login to your AWS management console and search for s3 in the search bar.

Image description

Step 2: Create an S3 Bucket

  • Click on create a bucket
  • Choose General purpose
  • Enter a unique name for your bucket
  • Ensure Block all public access is selected. Leave the rest of the settings at their default values and click Create bucket.

Image description

Step 3: Upload Website Files

Once your bucket is successfully created:

  • Click on the newly created bucket.
  • Upload your index.html, css , javascript , and any other static files.

Image description

Step 4: Set Up CloudFront Distribution

Now, we'll set up a CloudFront Distribution.

  • Navigate to CloudFront in AWS Console.

Image description

  • Click Create Distribution.
  • Create a new Origin Access Control (OAC) to securely grant CloudFront access to your S3 bucket.

Image description

  • Set Redirect HTTP TO HTTPS
  • Since this is a basic tutorial, your website won't need WAF.

Image description
Once you’ve completed the setup, AWS will create your CloudFront distribution.

Step 5: Update the s3 Bucket Policy

After creating the CloudFront distribution, you'll see a prompt asking you to update your S3 bucket policy. This step is important to allow CloudFront access the content in your bucket.

Image description
Copy the policy, head over to your s3 bucket permissions tab and paste the new policy in the Bucket Policy Editor and save the changes.

Image description

Step 6: Access Your Website

Copy the Distribution Domain Name from CloudFront, open it in your browser, and you will see your static website!

Image description

Conclusion

You've now successfully hosted a static website using Amazon S3 and Amazon CloudFront. With S3 providing scalable storage and CloudFront ensuring fast, reliable content delivery through its edge locations, your website is well-optimized for performance and availability.


This content originally appeared on DEV Community and was authored by Stephanie Albert


Print Share Comment Cite Upload Translate Updates
APA

Stephanie Albert | Sciencx (2024-09-27T17:07:30+00:00) Hosting a Static Website On S3 bucket With CloudFront.. Retrieved from https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/

MLA
" » Hosting a Static Website On S3 bucket With CloudFront.." Stephanie Albert | Sciencx - Friday September 27, 2024, https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/
HARVARD
Stephanie Albert | Sciencx Friday September 27, 2024 » Hosting a Static Website On S3 bucket With CloudFront.., viewed ,<https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/>
VANCOUVER
Stephanie Albert | Sciencx - » Hosting a Static Website On S3 bucket With CloudFront.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/
CHICAGO
" » Hosting a Static Website On S3 bucket With CloudFront.." Stephanie Albert | Sciencx - Accessed . https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/
IEEE
" » Hosting a Static Website On S3 bucket With CloudFront.." Stephanie Albert | Sciencx [Online]. Available: https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/. [Accessed: ]
rf:citation
» Hosting a Static Website On S3 bucket With CloudFront. | Stephanie Albert | Sciencx | https://www.scien.cx/2024/09/27/hosting-a-static-website-on-s3-bucket-with-cloudfront/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.