{"id":50480174,"url":"https://github.com/tux86/static-website-hosting-amazon-s3","last_synced_at":"2026-06-01T17:01:40.609Z","repository":{"id":199354894,"uuid":"702703614","full_name":"tux86/static-website-hosting-amazon-s3","owner":"tux86","description":"Deploy a secure \u0026 highly available static website on AWS using S3, CloudFront, ACM and Route53 with Terraform","archived":false,"fork":false,"pushed_at":"2023-10-15T20:01:04.000Z","size":1073,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-10-17T04:17:02.472Z","etag":null,"topics":["acm","aws","cloudfront","cloudfront-functions","oac","route53","s3","s3-bucket","serverless","static-site","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tux86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-09T20:49:08.000Z","updated_at":"2023-10-16T04:26:38.000Z","dependencies_parsed_at":"2023-10-13T10:28:55.257Z","dependency_job_id":"a2302353-545f-4524-8d63-48fa4b442b40","html_url":"https://github.com/tux86/static-website-hosting-amazon-s3","commit_stats":null,"previous_names":["tux86/static-website-hosting-amazon-s3"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/tux86/static-website-hosting-amazon-s3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tux86%2Fstatic-website-hosting-amazon-s3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tux86%2Fstatic-website-hosting-amazon-s3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tux86%2Fstatic-website-hosting-amazon-s3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tux86%2Fstatic-website-hosting-amazon-s3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tux86","download_url":"https://codeload.github.com/tux86/static-website-hosting-amazon-s3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tux86%2Fstatic-website-hosting-amazon-s3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33784631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acm","aws","cloudfront","cloudfront-functions","oac","route53","s3","s3-bucket","serverless","static-site","terraform"],"created_at":"2026-06-01T17:01:38.822Z","updated_at":"2026-06-01T17:01:40.552Z","avatar_url":"https://github.com/tux86.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Static Website Hosting on AWS with Terraform\n\nThis project sets up a static website hosting on AWS using Terraform. The architecture leverages AWS Route 53, CloudFront, S3, Certificate Manager, and a CloudFront Function to provide a highly available, scalable, and secure solution.\n\n## Further Reading\n\nFor a deeper understanding of this project and mastering static website hosting on AWS with Terraform, I recommend reading the following article on Medium:\n\n[Mastering Static Website Hosting on AWS with Terraform: A Step-by-Step Tutorial](https://medium.com/@walid.karray/mastering-static-website-hosting-on-aws-with-terraform-a-step-by-step-tutorial-5401ccd2f4fb)\n\n## Architecture Diagram\n\n![architecture-diagram-aws-static-website](https://github.com/tux86/static-website-hosting-amazon-s3/assets/9397970/5023726f-1887-49e4-b845-1cd6da959ec2)\n\n- **Client**: End user accessing the website.\n- **Route53**: AWS's Domain Name System (DNS) service that resolves DNS queries.\n- **Certificate Manager (TLS Certificate)**: Manages SSL/TLS certificates for HTTPS communication.\n- **CloudFront Distribution**: Content Delivery Network (CDN) service for serving cached or original content from S3.\n- **CloudFront OAC + S3 Bucket Policy**: Secures S3 bucket access to authorized CloudFront distributions using Origin Access Control (OAC).\n- **CloudFront Function**: Handles HTTP redirects for domain consistency.\n- **Private S3 Bucket**: Stores website’s static assets with restricted direct public access.\n- **Static Web Files**: HTML, CSS, and JavaScript files constituting the static website content.\n\n## Getting Started\n\n### Prerequisites:\n\n- Install [Terraform](https://www.terraform.io/downloads.html)\n- Configure AWS CLI with appropriate credentials.\n\n### Configuring Variables:\n\nBefore deploying the infrastructure, it's crucial to set up the necessary variables. Terraform utilizes variables to manage settings in a flexible manner. Follow the steps below to configure your variables:\n\n**Creating a Variables File**:\n- Create a file named `terraform.tfvars` in the project root.\n- This file will hold the values for the variables defined in `variables.tf`.\n\n```plaintext\n# Example terraform.tfvars content\n\naws_region  = \"us-west-2\"\nprefix      = \"your-org-prefix\"\ndomain_name = \"yourdomain.com\"\nbucket_name = \"website-name-frontend\"\ncommon_tags =  {\n  ManagedBy = \"Terraform\"\n  Org       = \"My Organization name\"\n  Project   = \"Static Website\"\n}\n```\n### Deploy to AWS:\n\n1. **Initialize Terraform**:\n   ```bash\n   terraform init\n   ```\n\n2. **Generate an Execution Plan**:\n   ```bash\n   terraform plan\n   ```\n\n3. **Apply the Configuration**:\n   ```bash\n   terraform apply\n   ```\n\n###  Cleanup\n\nTo destroy the provisioned infrastructure, use:\n\n```sh\nterraform destroy\n```\n\n## Thank You\n\nI appreciate your interest in this project and thank you for taking the time to explore it. Your involvement is crucial to the success and the community around the project.\n\n## Contribution\n\nContributions to this project are welcomed! Whether it's reporting bugs, suggesting enhancements, or writing and refactoring code, your help is always appreciated. Feel free to open an issue or create a pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftux86%2Fstatic-website-hosting-amazon-s3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftux86%2Fstatic-website-hosting-amazon-s3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftux86%2Fstatic-website-hosting-amazon-s3/lists"}