{"id":21725395,"url":"https://github.com/jameswoolfenden/terraform-aws-statebucket","last_synced_at":"2026-02-16T14:33:54.205Z","repository":{"id":81359252,"uuid":"159968852","full_name":"JamesWoolfenden/terraform-aws-statebucket","owner":"JamesWoolfenden","description":"Contains the module, permissions and sample code to create a state bucket for further Terraform use.","archived":false,"fork":false,"pushed_at":"2022-09-20T14:31:55.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-12T09:43:10.761Z","etag":null,"topics":["aws","module","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamesWoolfenden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-01T17:19:14.000Z","updated_at":"2022-09-20T14:28:36.000Z","dependencies_parsed_at":"2023-07-11T10:36:28.141Z","dependency_job_id":null,"html_url":"https://github.com/JamesWoolfenden/terraform-aws-statebucket","commit_stats":null,"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"purl":"pkg:github/JamesWoolfenden/terraform-aws-statebucket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-statebucket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-statebucket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-statebucket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-statebucket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesWoolfenden","download_url":"https://codeload.github.com/JamesWoolfenden/terraform-aws-statebucket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-statebucket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29510210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aws","module","terraform"],"created_at":"2024-11-26T03:17:27.398Z","updated_at":"2026-02-16T14:33:54.199Z","avatar_url":"https://github.com/JamesWoolfenden.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-aws-statebucket\n\n[![Build Status](https://github.com/JamesWoolfenden/terraform-aws-statebucket/workflows/Verify%20and%20Bump/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-aws-statebucket)\n[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-aws-statebucket.svg)](https://github.com/JamesWoolfenden/terraform-aws-statebucket/releases/latest)\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-aws-statebucket.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-aws-statebucket/releases/latest)\n![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-aws-statebucket/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-statebucket\u0026benchmark=CIS+AWS+V1.2)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-aws-statebucket/general)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-statebucket\u0026benchmark=INFRASTRUCTURE+SECURITY)\n\nTerraform module to provision a secure terraform state bucket for team use of IAC.\n\n---\n\nIt's 100% Open Source and licensed under the [APACHE2](LICENSE).\n\n## Versions\n\n| Terraform Version | Statebucket Release |\n| :---------------: | :-----------------: |\n|      0.12.x       |        0.3.0        |\n|      0.11.x       |       0.2.25        |\n\n## Usage\n\nInclude this repository as a module in your existing Terraform code:\n\n```HCL\nmodule statebucket {\n  source      = \"JamesWoolfenden/statebucket/aws\"\n  version     = \"0.3.1\"\n}\n```\n\nSet-up as per example.\n\nUse the generated `remote_state.tf` and change the bucket key for each subsequent service as required\n\n```hcl\nterraform {\n...\n\n  backend \"s3\" {\n    ...\n\n    key = \"\u003cyour-service\u003e/\u003cprovider-service\u003e/terraform.tfstate\"\n    ...\n  }\n}\n```\n\n## Instructions\n\nWhen working with Terraform as part of a team, instead of a local **terraform.tfstate** file, a shared remote state store is required, for AWS this is a S3 bucket.\nBut if we want to automate everything via Terraform?\nTraditionally we would have to create the initial bucket by hand via the console or by the cli and the resource unmanaged.\nThe module and example solves the issue of creating a state bucket in Terraform using Terraform itself.\n\n### Chicken then Egg\n\nThe Makefile in folder _examples\\examplesA_ has a number of tasks, one specifically to create the initial bucket:\n\n```sh\nmake first\n```\n\nThis makes the lock DB table, the state (S3) bucket, fills out and creates the remote_state.tf file and then copies the state from the local disk to the bucket.PHEW. The State of the bucket is now managed along with any future resources.\n\nOn the second and subsequent runs you use:\n\n```sh\nmake build\n```\n\n## Features\n\nThis module implements state locking via DynamoDB, Versioning on files within the bucket and finally MFA Based deletes of the bucket itself.\n\nThe module also uses a tagging based on the map variable common_tags scheme.\n\nThis Scheme here uses as a minimum (see _examplea.auto.tfvars_):\n\n```HCL\ncommon_tags = {\n  application = \"terraform\"\n  module      = \"statebucket\"\n  environment = \"develop\"\n  authors     = \"James Woolfenden, Oliver Smit\"\n}\n```\n\n## Costs\n\n```text\n Monthly cost estimate\n\nProject: .\n\n Name                                                           Monthly Qty  Unit                Monthly Cost\n\n module.statebucket.aws_dynamodb_table.dynamodb-state-lock\n ├─ Write capacity unit (WCU)                                        14,600  WCU-hours                 $11.27\n ├─ Read capacity unit (RCU)                                         14,600  RCU-hours                  $2.25\n ├─ Data storage                                            Cost depends on usage: $0.30 per GB-months\n ├─ Point-In-Time Recovery (PITR) backup storage            Cost depends on usage: $0.24 per GB-months\n ├─ On-demand backup storage                                Cost depends on usage: $0.12 per GB-months\n ├─ Table data restored                                     Cost depends on usage: $0.18 per GB\n └─ Streams read request unit (sRRU)                        Cost depends on usage: $0.000000237 per sRRUs\n\n module.statebucket.aws_s3_bucket.state_bucket\n └─ Standard\n    ├─ Storage                                              Cost depends on usage: $0.02 per GB-months\n    ├─ PUT, COPY, POST, LIST requests                       Cost depends on usage: $0.0053 per 1k requests\n    ├─ GET, SELECT, and all other requests                  Cost depends on usage: $0.00042 per 1k requests\n    ├─ Select data scanned                                  Cost depends on usage: $0.00225 per GB-months\n    └─ Select data returned                                 Cost depends on usage: $0.0008 per GB-months\n\n PROJECT TOTAL                                                                                         $13.53\n\n```\n\n\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Requirements\n\nNo requirements.\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | n/a |\n| \u003ca name=\"provider_local\"\u003e\u003c/a\u003e [local](#provider\\_local) | n/a |\n| \u003ca name=\"provider_template\"\u003e\u003c/a\u003e [template](#provider\\_template) | n/a |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_dynamodb_table.dynamodb-state-lock](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |\n| [aws_s3_bucket.state_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |\n| [aws_s3_bucket_acl.state_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |\n| [aws_s3_bucket_public_access_block.state_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |\n| [aws_s3_bucket_server_side_encryption_configuration.state_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |\n| [aws_s3_bucket_versioning.state_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |\n| [local_file.remote_state](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource |\n| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n| [template_file.remote_state](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_acl\"\u003e\u003c/a\u003e [acl](#input\\_acl) | Not Likely/Unwise to want a public state bucket, but here's the option | `string` | `\"private\"` | no |\n| \u003ca name=\"input_force_destroy\"\u003e\u003c/a\u003e [force\\_destroy](#input\\_force\\_destroy) | Set force\\_destroy property - unlikely to anything else but may want rid of at some point | `bool` | `false` | no |\n| \u003ca name=\"input_sse_algorithm\"\u003e\u003c/a\u003e [sse\\_algorithm](#input\\_sse\\_algorithm) | The type of encryption algorithm to use | `string` | `\"aws:kms\"` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_bucket_domain_name\"\u003e\u003c/a\u003e [bucket\\_domain\\_name](#output\\_bucket\\_domain\\_name) | The FQDN for the bucket |\n| \u003ca name=\"output_statebucket\"\u003e\u003c/a\u003e [statebucket](#output\\_statebucket) | The state bucket details |\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n\n## Policy\n\nThis is the policy required to build this project:\n\n\u003c!-- BEGINNING OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\nThe Terraform resource required is:\n\n```golang\nresource \"aws_iam_policy\" \"terraform_pike\" {\n  name_prefix = \"terraform_pike\"\n  path        = \"/\"\n  description = \"Pike Autogenerated policy from IAC\"\n\n  policy = jsonencode({\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"dynamodb:CreateTable\",\n                \"dynamodb:DeleteTable\",\n                \"dynamodb:DescribeContinuousBackups\",\n                \"dynamodb:DescribeTable\",\n                \"dynamodb:DescribeTimeToLive\",\n                \"dynamodb:ListTagsOfResource\",\n                \"dynamodb:UpdateTable\",\n                \"dynamodb:UpdateTimeToLive\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor1\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"s3:CreateBucket\",\n                \"s3:DeleteBucket\",\n                \"s3:GetAccelerateConfiguration\",\n                \"s3:GetBucketAcl\",\n                \"s3:GetBucketCORS\",\n                \"s3:GetBucketLogging\",\n                \"s3:GetBucketObjectLockConfiguration\",\n                \"s3:GetBucketPolicy\",\n                \"s3:GetBucketPublicAccessBlock\",\n                \"s3:GetBucketRequestPayment\",\n                \"s3:GetBucketTagging\",\n                \"s3:GetBucketVersioning\",\n                \"s3:GetBucketWebsite\",\n                \"s3:GetEncryptionConfiguration\",\n                \"s3:GetLifecycleConfiguration\",\n                \"s3:GetObject\",\n                \"s3:GetObjectAcl\",\n                \"s3:GetReplicationConfiguration\",\n                \"s3:ListAllMyBuckets\",\n                \"s3:ListBucket\",\n                \"s3:PutBucketAcl\",\n                \"s3:PutBucketPublicAccessBlock\",\n                \"s3:PutBucketVersioning\",\n                \"s3:PutEncryptionConfiguration\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n})\n}\n\n\n```\n\u003c!-- END OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\n\n## Checkov Security tests\n\nThis module is scanned by Checkov - \u003chttps://checkov.io\u003e and has 2 exclusions added:\n\n```checkov\n  #checkov:skip=CKV_AWS_18: \"Ensure the S3 bucket has access logging enabled\"\n  #checkov:skip=CKV_AWS_52: \"Ensure S3 bucket has MFA delete enabled\"\n```\n\nThese are added because access logging was not required, and that MFA delete was unsuitable and difficult to automate.\n\n## Related Projects\n\nCheck out these related projects.\n\n- [terraform-aws-s3](https://github.com/jameswoolfenden/terraform-aws-s3) - S3 buckets\n\n## Help\n\n**Got a question?**\n\nFile a GitHub [issue](https://github.com/JamesWoolfenden/terraform-aws-statebucket/issues).\n\n## Contributing\n\n### Bug Reports \u0026 Feature Requests\n\nPlease use the [issue tracker](https://github.com/JamesWoolfenden/terraform-aws-statebucket/issues) to report any bugs or file feature requests.\n\n## Copyrights\n\nCopyright © 2019-2022 James Woolfenden\n\n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nSee [LICENSE](LICENSE) for full details.\n\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n\u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied. See the License for the\nspecific language governing permissions and limitations\nunder the License.\n\n### Contributors\n\n[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]\u003cbr/\u003e[James Woolfenden][jameswoolfenden_homepage]\u003cbr/\u003e[![Oliver Smit][olmesm_avatar]][olmesm_homepage]\u003cbr/\u003e[Oliver Smit][olmesm_homepage]\n\n[jameswoolfenden_homepage]: https://github.com/jameswoolfenden\n[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150\n[olmesm_homepage]: https://github.com/olmesm\n[olmesm_avatar]: https://github.com/olmesm.png?size=150\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-statebucket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-statebucket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-statebucket/lists"}