Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/l2fprod/cos-terraform-backend
Use a COS bucket as a terraform backend
https://github.com/l2fprod/cos-terraform-backend
cloud-object-storage ibm-cloud s3 terraform
Last synced: 1 day ago
JSON representation
Use a COS bucket as a terraform backend
- Host: GitHub
- URL: https://github.com/l2fprod/cos-terraform-backend
- Owner: l2fprod
- License: other
- Created: 2021-04-16T19:35:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T18:44:04.000Z (about 1 year ago)
- Last Synced: 2023-11-18T19:54:33.044Z (almost 1 year ago)
- Topics: cloud-object-storage, ibm-cloud, s3, terraform
- Language: HCL
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Using Cloud Object Storage as a backend
This repository shows how to use IBM Cloud Object Storage (COS) as a backend to store terraform state through COS [Terraform S3 compatibility](https://www.terraform.io/docs/backends/types/s3.html).
1. Create a COS instance and bucket in IBM Cloud. Terraform is used in this step to create the COS service and the bucket as it is easier than to list all instructions that you would need to perform in the UI or the CLI.
```sh
cd 010-prepare-backend
terraform init
terraform apply
```> It generates a `backend.tf` file in `020-use-backend` with the COS service instance and bucket information. Later instead of hardcoding the values in `backend.tf`, you can use environment variables to initialize the backend as described in https://www.terraform.io/docs/language/settings/backends/s3.html.
2. Test the backend.
```sh
cd 020-use-backend
terraform init
terraform apply
```3. Look into your COS bucket for a file named `global.state`.
## Enable object versioning
You can benefit from COS built-in object versioning by changing the definition of the COS bucket in `010-prepare-backend/main.tf` to include the [object_versioning flag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#object_versioning).
## License
This project is licensed under the Apache License Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0).