{"id":17720144,"url":"https://github.com/theden/static-website","last_synced_at":"2026-01-08T09:05:19.321Z","repository":{"id":228971406,"uuid":"614182727","full_name":"TheDen/static-website","owner":"TheDen","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-15T04:29:29.000Z","size":64,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-30T01:18:37.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/TheDen.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,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-15T04:01:07.000Z","updated_at":"2023-03-15T04:02:47.000Z","dependencies_parsed_at":"2024-03-21T12:42:54.466Z","dependency_job_id":null,"html_url":"https://github.com/TheDen/static-website","commit_stats":null,"previous_names":["theden/static-website"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDen%2Fstatic-website","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDen%2Fstatic-website/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDen%2Fstatic-website/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDen%2Fstatic-website/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheDen","download_url":"https://codeload.github.com/TheDen/static-website/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246473279,"owners_count":20783236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-25T15:26:26.606Z","updated_at":"2026-01-08T09:05:14.301Z","avatar_url":"https://github.com/TheDen.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Static S3 Website\n\n- [Static S3 Website](#static-s3-website)\n  * [Overview](#overview)\n  * [Assumptions/Considerations](#assumptionsconsiderations)\n- [Setup](#setup)\n- [Deploy](#deploy)\n- [Test](#test)\n- [Improvements, Alternative Solutions, Productionising](#improvements-alternative-solutions-productionising)\n\n## Overview \n\nTerraform to create an s3 bucket `theden-static-website` with the default_root_object `index.html` (as defined in `bucket_data/index.html`), and a CloudFront distribution with the bucket as its origin.\n\n## Assumptions/Considerations\n\n* Scoped for a simple development environment, within AWS free tier usage, hence\n  * No custom additional `CNAME` for the CloudFront distribution\n  * Logging disabled for CloudFront\n  * Default S3 config for encryption, lifecycles, logging, and versioning (mostly `none`)\n* Configured to default to the `ap-southeast-2` AWS region\n* `CachingOptimized` for the S3 origin (as recommended by AWS\n* Georestricted to `Australia`\n* Assumes the `default` AWS profile is set\n\n\n# Setup\n\nTo initialise the working directory\n\n```shell\nTerraform init\n```\n\nTo validate \n\n```shell\nterraform validate\n```\n\nFor debugging \n\n```shell\nterraform console\n```\n\n# Deploy\n\n```shell\nTerraform plan\n```\n\n```shell\nTerraform apply\n```\n\nTo see the output values, e.g.,\n\n```shell\nterraform output\ncloudfront_etag = \"E3Q70LPF8BDW12\"\ns3_bucket_arn = \"arn:aws:s3:::theden-static-website\"\ns3_bucket_id = \"theden-static-website\"\nstatic_website_url = \"https://d3w1hji9oouxbr.cloudfront.net\"\n```\n\n# Test\n\nThe [Terratest](https://github.com/gruntwork-io/terratest/) library is used to test the terraform deployment and check if the CloudFront `index.html` endpoint returns `200`\n\nTo pull in the dependencies\n\n```shell\ncd test\ngo mod init \"github.com/static-website\"\ngo mod tidy\n```\n\nTo run the tests, in the `test` folder run\n\n```shell\ngo test\n```\n\n# Improvements, Alternative Solutions, Productionising\n\nPotential improvements\n \n* Set up different environments with terraform, using terraform workspaces \n* Manage the terraform state in S3 or elsewhere\n* `terraform plan` and `apply` via CI, and show diff in PR comments\n* Add more linters and static analysis tools in the CI, e.g., [tfsec](https://github.com/aquasecurity/tfsec), run `terraform validate`, [checkcov](https://github.com/bridgecrewio/checkov), [tflint](https://github.com/terraform-linters/tflint), check with `go fmt`\n* Add a `Makefile` for the go code (and potentially terraform)\n* Invalidate CloudFront cache (or specific path) on changes to the bucket data \n* Add a `CODEOWNERS` file\n\nAlternative solutions\n\n* Use buckets on Google Cloud, with Cloud DNS\n* Simplest solution would be to use GitHub pages to with a `gh-pages` branch for deployment, though you lose configurability with respect to the CDN configuration\n* Use AWS Amplify\n* Could use CloudFormation instead of terraform to build the infra\n* If a Kubernetes cluster already exists, it can be deployed with something like `ingress-nginx`\n\nProductionising\n\n* Use Route53 as a `CNAME` for CloudFront, and use `ACM`\n* Set up different environments for the infrastructure, ideally isolated \n* Configure CloudFront response header policy for what's required\n* Add encryption to buckets, and potentially versioning\n* Minify the static files prior to uploading to the bucket\n* Add GitHub branch protection and and potentially an approval process\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheden%2Fstatic-website","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheden%2Fstatic-website","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheden%2Fstatic-website/lists"}