Files
opentf/website/docs/language/settings/backends/cos.html.md
Chris Arcand f521ba6cd7 Remove 'enhanced' backend type distinction
As explained in the changes: The 'enhanced' backend terminology, which
only truly pertains to the 'remote' backend with a single API (Terraform
Cloud/Enterprise's), has been found to be a confusing vestige which need
only be explained in the context of the 'remote' backend.

These changes reorient the explanation(s) of backends to pertain more
directly to their primary purpose, which is storage of state snapshots
(and not implementing operations).

That Terraform operations are still _implemented_ by the literal
`Backend` and `Enhanced` interfaces is inconsequential a user of
Terraform, an internal detail.
2021-12-07 16:29:51 -06:00

2.5 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
language Backend Type: cos docs-backends-types-standard-cos Terraform can store the state remotely, making it easier to version and work with in a team.

COS

Stores the state as an object in a configurable prefix in a given bucket on Tencent Cloud Object Storage (COS).

This backend supports state locking.

~> Warning! It is highly recommended that you enable Object Versioning on the COS bucket to allow for state recovery in the case of accidental deletions and human error.

Example Configuration

terraform {
  backend "cos" {
    region = "ap-guangzhou"
    bucket = "bucket-for-terraform-state-1258798060"
    prefix = "terraform/state"
  }
}

This assumes we have a COS Bucket created named bucket-for-terraform-state-1258798060, Terraform state will be written into the file terraform/state/terraform.tfstate.

Data Source Configuration

To make use of the COS remote state in another configuration, use the terraform_remote_state data source.

data "terraform_remote_state" "foo" {
  backend = "cos"

  config = {
    region = "ap-guangzhou"
    bucket = "bucket-for-terraform-state-1258798060"
    prefix = "terraform/state"
  }
}

Configuration variables

The following configuration options or environment variables are supported:

  • secret_id - (Optional) Secret id of Tencent Cloud. It supports environment variables TENCENTCLOUD_SECRET_ID.
  • secret_key - (Optional) Secret key of Tencent Cloud. It supports environment variables TENCENTCLOUD_SECRET_KEY.
  • region - (Optional) The region of the COS bucket. It supports environment variables TENCENTCLOUD_REGION.
  • bucket - (Required) The name of the COS bucket. You shall manually create it first.
  • prefix - (Optional) The directory for saving the state file in bucket. Default to "env:".
  • key - (Optional) The path for saving the state file in bucket. Defaults to terraform.tfstate.
  • encrypt - (Optional) Whether to enable server side encryption of the state file. If it is true, COS will use 'AES256' encryption algorithm to encrypt state file.
  • acl - (Optional) Object ACL to be applied to the state file, allows private and public-read. Defaults to private.