The Challenge
You need a quick, low-cost way to host a static website without setting up servers or a CDN. S3 static website hosting serves HTML files directly from a bucket, making it the simplest path to getting a site online on AWS.
What You'll Build
- → S3 bucket configured for static website hosting
- → HTML files uploaded from a local directory
- → Public read access for website visitors
- → Index and error document routing configured
Try This Prompt in Pulumi Neo
Run this prompt in Neo to deploy your infrastructure, or edit it to customize.
Best For
Architecture Overview
S3 static website hosting is the simplest way to serve a website on AWS. You create a bucket, upload your HTML files, enable static website hosting, and S3 serves pages directly over HTTP. There are no servers to configure, no scaling decisions to make, and no infrastructure to maintain beyond the bucket itself.
The bucket is configured with an index document that S3 returns when visitors request the root URL or a directory path, and an error document that handles requests for pages that do not exist. This gives you clean URL routing without any application server.
Public access is granted at the bucket level so that anyone on the internet can view your site. S3 charges based on storage used and requests served, which makes this approach extremely cost-effective for low-traffic sites. For most simple websites, the monthly cost is pennies.
Bucket Configuration
The S3 bucket enables the static website hosting feature, which tells AWS to serve the bucket contents as a website rather than raw object storage. This activates URL routing (index and error documents) and provides a website endpoint URL. The bucket name does not need to match a domain name unless you plan to use Route53 for custom domain routing.
File Upload
HTML files are uploaded as S3 objects from a local directory. Each file gets a text/html content type so browsers render them correctly rather than downloading them. You can organize files in subdirectories to create nested URL paths. Adding new pages or updating existing ones is a matter of uploading new objects.
Public Access
The bucket policy grants public read access to all objects, allowing anyone to request pages through the website endpoint. This is appropriate for public-facing content but means everything in the bucket is accessible. For sensitive content, consider the CloudFront-based pattern instead, which keeps the bucket private and controls access through the CDN.
Common Customizations
- Add a custom domain: Use Route53 to point your domain at the S3 website endpoint. The bucket name must match the domain name for this to work with S3’s built-in domain support.
- Enable HTTPS: S3 website endpoints only support HTTP. For HTTPS, add a CloudFront distribution in front of the bucket with an ACM certificate.
- Upload additional file types: Extend the deployment to handle CSS, JavaScript, and image files by setting the appropriate content types for each file extension.
- Add lifecycle rules: Configure S3 lifecycle policies to automatically delete old versions or transition infrequently accessed content to cheaper storage classes.
Related Prompts
Deploy a Static Website with S3 and CloudFront CDN
You need to host a static website with fast global delivery, HTTPS encryption, and custom domain support. This pattern …
Create a Simple S3 Bucket
You need a secure S3 bucket to store files or assets, or you want to test your Pulumi Neo setup with the simplest …
Build a Storage Solution
Applications need durable, secure file storage that protects data while controlling costs as storage grows. S3 provides …
Deploy a Static Website
You need a fast, secure way to serve a static website globally. Whether it is a marketing site, documentation portal, or …