Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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).