# mhhsd-test — S3 Static Website (Terraform)
This Terraform config creates an **S3 bucket**, enables **S3 static website hosting**, uploads your local site files, and outputs the **website URL**.
> Note: The **S3 Website Endpoint is HTTP only**. If you want HTTPS + a locked-down bucket, use **CloudFront** in front of S3 instead.
---
## What it creates
- S3 bucket (optionally `force_destroy = true` for easy teardown)
- S3 Website hosting configuration (`index.html` / `error.html`)
- Public read access for objects (required for S3 website endpoint)
- Uploads files from a local directory to the bucket
- Outputs the website URL + bucket name
---
## Prerequisites
- Terraform installed (`terraform -version`)
- AWS credentials available to Terraform (pick one):
- `AWS_PROFILE=default` (or your profile)
- `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`
- SSO or other supported auth
- Your website folder exists locally (example):
- `C:/Users/okano/Downloads/mhhsd-test`
- Your site includes at least:
- `index.html`
- `style.css`
- (optional but recommended) `error.html`
---
## Files
Typical layout:
```text
.
├── main.tf
├── variables.tf
├── outputs.tf
└── providers.tf| Variable | Default | Description |
|---|---|---|
aws_region |
us-east-1 |
AWS region to deploy into |
bucket_name |
mhhsd-test |
S3 bucket name (must be globally unique) |
site_dir |
C:/Users/okano/Downloads/mhhsd-test |
Local path to your website folder |
index_document |
index.html |
Website index file |
error_document |
error.html |
Website error file |
Bucket names are global. If
mhhsd-testis taken, changebucket_nameto something unique.
From the Terraform folder:
terraform init
terraform plan
terraform applyAfter apply, Terraform prints the outputs.
bucket_name— the created bucket namewebsite_endpoint— S3 website endpointwebsite_url— full HTTP URL you can open in a browser
Example:
website_url = "http://mhhsd-test.s3-website-us-east-1.amazonaws.com"
- Edit files in your local
site_dir - Re-run:
terraform applyTerraform will re-upload changed files using hashes/ETags.
force_destroy = true):
terraform destroyThis configuration intentionally allows public read to support the S3 Website Endpoint.
- Public access block is disabled for this bucket
- Bucket policy allows
s3:GetObjectto everyone - No bucket listing permission is granted