Ref: https://learn.cantrill.io/courses/1820301/lectures/41301470
DEMO: https://learn.cantrill.io/courses/1820301/lectures/41301471
S3 Static HTTP Website Hosting (S3 Bucket as Static Website)
- Normal access to S3 objects is via APIs → secure & flexible
- 💡 CLI & AWS Management Console UI use APIs behind the scenes
- 🔧 S3 Static Website Hosting: allows access to S3 objects via HTTP
- The S3 bucket can become a static website
- Useful for e.g. blogs, portfolio websites…
- 👍 Quite simple to set up and use:
- Enable the feature in the S3 bucket and set Index & Error documents (HTML documents)
- Index page → default page, returned when requesting the website and not something specific (entry point to most websites)
- Error page → used when something goes wrong (e.g. HTTP 404)
- Website endpoint created → can access the S3 bucket via HTTP via given IP address
- Default endpoint/address comes predefined by AWS
- For custom endpoint/address, you need to pay for your DNS domain
- ‼️ If accessing endpoint via browser, must first disable “Block Public Access” settings in the bucket!!
- ‼️ Without Amazon CloudFront, you can only access the S3 bucket via HTTP, not HTTPS!
- 💡 We will expose the static website via CloudFront in a later section, and enable HTTPS
- Custom Domain Endpoint via Amazon Route 53 → Example:
- Purchase domain
example.org
in R53
- Create bucket and name it
example.org
- Create a DNS resource in R53 to route to the S3 bucket
- 💡 This will also be part of the demo in the CloudFront section of the course
S3 Static Website Hosting - Use Cases
Diagram: https://github.com/acantril/aws-sa-associate-saac03/blob/main/0700-SIMPLE_STORAGE_SERVICE(S3)/00_LEARNINGAIDS/S3StaticHosting-1.png
- Offloading: offload heavy media from compute services into S3
- S3 is designed for storage of large data at scale
- S3 storage is much cheaper than storage in a compute service
- Example: move photos from EC2 instance into S3, make photos available via HTTP, have EC2 instance return HTTP address of a photo when queried by client
- Out-of-band pages: easy place to host a static failover page when main service is down
- Good practice to serve these pages from a different service (if your EC2 server is down, it could be possible all of EC2 is down → serving from S3 will be )
- Example: you host your main website from an EC2 instance. If server is down (e.g. due to maintenance), configure DNS to failover to an error/status static page in S3
- Simple static websites: blogs, portfolio websites…
S3 Billing
- ❗ S3 is INCREDIBLY cheap, even outside the Free Tier!
- Extremely popular storage service (was designed for this)
- S3 charges for:
- Storage
- Data transfer OUT of S3 (relevant for API and HTTP requests)
- ❗ Transferring data INTO S3 is FREE!
- Currently, 12-month Free Tier offers:
- Up to 5GB of standard storage
- Up to 20 000 GET requests per month
- Up to 2000 PUT requests per month
- 💡 And even when you go above the Free Tier, S3 is usually cheap and worth it! But always be aware of your costs!
- Always check documentation for up-to-date information: https://aws.amazon.com/s3/pricing/