{"id":25436730,"url":"https://github.com/p4irin/explore_terraform_localstack_s3_static_website","last_synced_at":"2026-04-12T23:36:25.623Z","repository":{"id":277215477,"uuid":"929407714","full_name":"p4irin/explore_terraform_localstack_s3_static_website","owner":"p4irin","description":"Setup an AWS S3 bucket on LocalStack to host my static Jekyll resume locally","archived":false,"fork":false,"pushed_at":"2025-02-12T18:21:01.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T19:32:26.389Z","etag":null,"topics":["aws-cli","aws-s3-bucket","explore","jekyll","localstack","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/p4irin.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,"publiccode":null,"codemeta":null}},"created_at":"2025-02-08T13:34:49.000Z","updated_at":"2025-02-12T18:21:05.000Z","dependencies_parsed_at":"2025-02-12T19:32:29.859Z","dependency_job_id":"5b580f74-3077-4fbc-ba22-97ace3bcc6f3","html_url":"https://github.com/p4irin/explore_terraform_localstack_s3_static_website","commit_stats":null,"previous_names":["p4irin/explore_terraform_localstack_s3_static_website"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_s3_static_website","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_s3_static_website/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_s3_static_website/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_s3_static_website/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4irin","download_url":"https://codeload.github.com/p4irin/explore_terraform_localstack_s3_static_website/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041794,"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":["aws-cli","aws-s3-bucket","explore","jekyll","localstack","terraform"],"created_at":"2025-02-17T08:22:12.156Z","updated_at":"2026-04-12T23:36:20.067Z","avatar_url":"https://github.com/p4irin.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Explore Terraform, AWS S3 static website on LocalStack\n\n1. Manually setup an AWS S3 bucket on Localstack with awscli to host my static Jekyll resume locally.\n1. Automate the above with Terraform\n\n## Prerequisites\n\n* [LocalStack](https://docs.localstack.cloud/getting-started/)\n* [Terraform](https://developer.hashicorp.com/terraform/install)\n* [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/)\n* [Jekyll](https://jekyllrb.com/docs/installation/ubuntu/)\n* [Static webiste](https://github.com/p4irin/resume.git)\n\n### My stack\n\n* Ubuntu 22.04.03 LTS Jammy on WSL 2.0.14.0\n* LocalStack CLI 4.1.0\n* Terraform 1.10.5\n* aws-cli 1.37.13\n* Jekyll 4.4.1\n\n## General steps\n\n1. `$ localstack start`\n1. Clone my Jekyll resume on GitHub\n1. Create an S3 bucket\n1. Attach a policy to the bucket\n1. Sync/upload files\n1. Enable static website hosting on the bucket\n1. `$ localstack stop`\n\n## Using AWS CLI\n\n###\n\n```bash\n$ localstack start\n```\n\n### Clone my Jekyll resume on GitHub\n\n```bash\n$ localstack start\n...\n$ git clone https://github.com/p4irin/resume.git\n$ cd resume\n```\n\nGenerate static website\n\n```bash\n$ bundle exec jekyll build\n```\nThis will generate a static website in a sub-directory `_site`.\n\n### Create an S3 bucket\n\n```bash\n$ aws --profile localstack s3api create-bucket --bucket myresume\n```\n### Attach a policy to the bucket\n\nAttach the bucket policy file `myresume_bucket_policy.json` to the bucket. Note the attribute \"Resource\" containing the bucket name in the path.\n\n```json\n\"Resource\": \"arn:aws:s3:::myresume/*\"\n```\n\nThis policy allows public access to its content.\nAttach the policy\n\n```bash\n$ aws --profile localstack s3api put-bucket-policy --bucket myresume --policy file://../myresume_bucket_policy.json\n```\n\n### Sync/upload files\n\n```bash\n$ aws --profile localstack s3 sync _site/ s3://myresume\n```\n\n### Enable static website hosting on the bucket\n\n```bash\naws --profile localstack s3 website s3://myresume/ --index-document index.html\n```\n\nCheck my resume on http://myresume.s3-website.localhost.localstack.cloud:4566/\n\n###\n\n```bash\n$ localstack stop\n```\n\n## Terraform\n\nRefer to the `*.tf` files.\n\n### \n\n### Provider configuration\n\nThe aws provider is configured in `provider.tf`. Note that `s3.localhost.localstack.cloud:4566` is used for the s3 endpoint\n\n```json\nendpoints {\n  s3 = \"http://s3.localhost.localstack.cloud:4566\"\n}\n```\n\nThis is recommended. S3 is a virtual hosted-style endpoint.\n\n### Variables\n\nDeclare and set the `bucket_name` var to _myresume_ in `variables.tf` and `variables.tfvars`\n\n### Outputs\n\nDisplay some info we can use/for context after Terraform is done in `outputs.tf`. Like the URL for the website.\n\n### Resources\n\nDeclare resources in `main.tf` in accordance to the general steps\n\n1. Clone my Jekyll resume on GitHub\n1. Create an S3 bucket\n1. Attach a policy to the bucket\n1. Sync/upload files\n1. Enable static website hosting on the bucket\n\n#### Clone Jekyll resume on Github and generate a static website\n\n\u003c!-- A `null_resource` type resource is used for this purpose.\nThe repo is cloned into a `resume/` directory and the static website is generated in `resume/_site` --\u003e\n\nClone the repo before running `terraform` `init` `plan` and `apply`.\nSee below.\n\n#### Create the bucket\n\n#### Attach a policy\n\nThe policy resource references the bucket so the dependency of the policy on the bucket is implied. The bucket is created before the policy is attached to it.\n\n#### Sync/upload files\n\nDependency on the bucket is explicit. It must be available in order to upload files. Everything below directory `_site` is uploaded.\n\n#### Enable static website hosting on the bucket\n\nReference the bucket and set the index_document. We'll skipp setting the error_document.\n\n#### Deploy the Jekyll resume\n\n```bash\n$ git clone https://github.com/p4irin/resume.git\n...\n$ cd resume\n$ bundle exec jekyll build\n...\n$ cd ..\n$ localstack start\n...\n$ terraform init\n...\n$ terraform plan\n...\n$ terraform apply\n...\n```\n\nWith the dependencies in place the resources should be created in the correct order. The Jekyll static website is now deployed to an S3 bucket on LocalStack. `terraform apply` shows the outputs.\n\n```bash\nApply complete! Resources: 4 added, 0 changed, 0 destroyed.\n\nOutputs:\n\narn = \"arn:aws:s3:::myresume\"\ndomain = \"s3-website-us-east-1.amazonaws.com\"\nname = \"myresume\"\nwebsite_endpoint = \"myresume.s3-website-us-east-1.amazonaws.com\"\n```\n\nThe domain and website_endpoint are specific to AWS and are not applicable when deploying to LocalStack.\n\nTo access the Jekyll generated static website on the LocalStack S3 bucket use http://myresume.s3-website.localhost.localstack.cloud:4566/.\n\n#### Cleaning up\n\n```bash\n$ localstack stop\n...\n```\n\n## References\n\n* [LocalStack S3](https://docs.localstack.cloud/user-guide/aws/s3/)\n* [AWS S3](https://docs.aws.amazon.com/s3/?icmpid=docs_homepage_featuredsvcs)\n* [LocalStack](https://www.localstack.cloud/)\n* [Terraform aws provider](https://registry.terraform.io/providers/hashicorp/aws/latest)\n* [Loacalstack awscli integration](https://docs.localstack.cloud/user-guide/integrations/aws-cli/)\n* [Jekyll](https://jekyllrb.com/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_s3_static_website","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_s3_static_website","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_s3_static_website/lists"}