An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
Creating a static website with Amazon S3
This project is a static website that shows the top 10 cat pictures ever using Amazon S3.
Stage 1: Creating an S3 bucket
Remember, every S3 bucket must have a unique name. My choice of using a domain URL as a bucket name is because I already registered a domain animals4life295.link with Route53 earlier in the course, since I would love to direct my bucket to my registered domain later in the project, my bucket name needs to correlate with my registered Route53 domain. I also unchecked block all public access so it can be used as a static website since it must be available to everybody. Unchecking this means we will be able to grant public access, although not automatically.
Stage 2: Enabling static website hosting and uploading files
Right now, I can only access the S3 API and control UI, but I need to be able to host our static website. So, I must enable static website hosting on my S3 bucket. I went to the properties tab of my bucket, scrolled to the bottom, and enabled static website hosting. I also set my index and error document.
After that, I uploaded my files and folders to my S3 bucket
Stage 3: Enabling static website hosting and uploading files
I tried accessing my static website after uploading my files, but I got an error page. Remember, I checked off block all public access in stage 1? Now, I need to define a bucket policy that makes the static website public.
I went to the permissions tab of my bucket and edited my pocket policy, which allows public read access to my S3 bucket. It worked!!
Stage 4: Directing my S3 bucket to my registered domain
Up till this point, I have been accessing my static website with my bucket website endpoint. I dont want that; I want to access my static website with a normal URL.
So, I moved to my Route53 console, went to Hosted Zones, and selected my animals4life295.link zone and then proceeded to add a record. The reason for doing that is to point my registered domain to my S3 bucket.
After setting and saving this record I was able to access my S3 bucket directly from a domain top10.animals4life295.link which is also the name of my bucket!
Original Link: https://dev.to/mohtasham/creating-a-static-website-with-amazon-s3-3e0g
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To