Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jameswoolfenden/terraform-gcp-statebucket
Contains a module to create a statebucket for use with Terraform
https://github.com/jameswoolfenden/terraform-gcp-statebucket
bucket gcp module state terraform
Last synced: 26 days ago
JSON representation
Contains a module to create a statebucket for use with Terraform
- Host: GitHub
- URL: https://github.com/jameswoolfenden/terraform-gcp-statebucket
- Owner: JamesWoolfenden
- License: apache-2.0
- Created: 2018-12-02T23:06:50.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-11T10:47:27.000Z (6 months ago)
- Last Synced: 2024-06-11T20:41:34.546Z (6 months ago)
- Topics: bucket, gcp, module, state, terraform
- Language: HCL
- Homepage:
- Size: 126 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# terraform-gcp-statebucket
[![Build Status](https://github.com/JamesWoolfenden/terraform-gcp-statebucket//workflows/Verify/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-gcp-statebucket)
[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-gcp-statebucket.svg)](https://github.com/JamesWoolfenden/terraform-gcp-statebucket/releases/latest)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-gcp-statebucket.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-gcp-statebucket/releases/latest)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-gcp-statebucket/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-gcp-statebucket&benchmark=CIS+AWS+V1.2)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-gcp-statebucket/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-gcp-statebucket&benchmark=INFRASTRUCTURE+SECURITY)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-gcp-statebucket/cis_gcp)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-gcp-statebucket&benchmark=CIS+GCP+V1.1)Terraform module to provision a secure terraform state bucket for team use of IAC.
---
It's 100% Open Source and licensed under the [APACHE2](LICENSE).
## Usage
Include this repository as a module in your existing terraform code:
```hcl
module "statebucket" {
source = "JamesWoolfenden/statebucket/gcp"
version = "0.3.22"
common_tags = var.common_tags
kms_key ="pike"
}
```## Requirements
No requirements.
## Providers
| Name | Version |
|------|---------|
| [google](#provider\_google) | n/a |
| [local](#provider\_local) | n/a |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [google_storage_bucket.statebucket](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket) | resource |
| [local_file.remote_state](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [common\_tags](#input\_common\_tags) | This is a map type for applying tags on resources | `map(any)` | n/a | yes |
| [kms\_key](#input\_kms\_key) | Which key to encrypt with | `string` | n/a | yes |
| [location](#input\_location) | n/a | `string` | n/a | yes |
| [project\_id](#input\_project\_id) | n/a | `string` | n/a | yes |## Outputs
| Name | Description |
|------|-------------|
| [bucket\_domain\_name](#output\_bucket\_domain\_name) | The Url of the statebucket |## Role and Permissions
The Terraform resource required is:
```golang
resource "google_project_iam_custom_role" "terraform_pike" {
project = "pike"
role_id = "terraform_pike"
title = "terraform_pike"
description = "A user with least privileges"
permissions = [
"storage.buckets.create",
"storage.buckets.delete",
"storage.buckets.get",
"storage.buckets.update"
]
}```
## Information
When working with Terraform as part of a team, instead of a local **terrraform.tfstate** file, a shared remote state store is required, for GCP this is the google_storage_bucket.
But if we want to automate everything via Terraform? Traditionally we would have to create the initial bucket by hand via the console or by the CLI and the resource unmanaged.
The module and example solve the issue of creating a state bucket in Terraform using Terraform itself.## But how
The Makefile in folder _examples\examplesA_ has several tasks, one specifically to create the initial bucket:
```make
make first
```This makes the lock DB table, the state (google_storage_bucket) 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.
On the second and subsequent runs, you use:
```make
make build
```If this is your first time using the APIs you will need to enable them:
## Related Projects
Check out these related projects.
- [terraform-aws-s3](https://github.com/jameswoolfenden/terraform-aws-s3) - S3 buckets
## Help
**Got a question?**
File a GitHub [issue](https://github.com/JamesWoolfenden/terraform-gcp-statebucket/issues).
## Contributing
### Bug Reports & Feature Requests
Please use the [issue tracker](https://github.com/JamesWoolfenden/terraform-gcp-statebucket/issues) to report any bugs or file feature requests.
## Copyrights
Copyright © 2019-2023 James Woolfenden
## License
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
See [LICENSE](LICENSE) for full details.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License atUnless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.### Contributors
[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]
[James Woolfenden][jameswoolfenden_homepage][jameswoolfenden_homepage]: https://github.com/jameswoolfenden
[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150