github.com/eliastor/durgaform@v0.0.0-20220816172711-d0ab2d17673e/website/docs/language/settings/backends/consul.mdx (about)

     1  ---
     2  page_title: 'Backend Type: consul'
     3  description: Terraform can store state in Consul.
     4  ---
     5  
     6  # consul
     7  
     8  Stores the state in the [Consul](https://www.consul.io/) KV store at a given path.
     9  
    10  This backend supports [state locking](/language/state/locking).
    11  
    12  ## Example Configuration
    13  
    14  ```hcl
    15  terraform {
    16    backend "consul" {
    17      address = "consul.example.com"
    18      scheme  = "https"
    19      path    = "full/path"
    20    }
    21  }
    22  ```
    23  
    24  Note that for the access credentials we recommend using a
    25  [partial configuration](/language/settings/backends/configuration#partial-configuration).
    26  
    27  ## Data Source Configuration
    28  
    29  ```hcl
    30  data "terraform_remote_state" "foo" {
    31    backend = "consul"
    32    config = {
    33      path = "full/path"
    34    }
    35  }
    36  ```
    37  
    38  ## Configuration Variables
    39  
    40  !> **Warning:**  We recommend using environment variables to supply credentials and other sensitive data. If you use `-backend-config` or hardcode these values directly in your configuration, Terraform will include these values in both the `.terraform` subdirectory and in plan files. Refer to [Credentials and Sensitive Data](/language/settings/backends/configuration#credentials-and-sensitive-data) for details.
    41  
    42  The following configuration options / environment variables are supported:
    43  
    44  - `path` - (Required) Path in the Consul KV store
    45  - `access_token` / `CONSUL_HTTP_TOKEN` - (Required) Access token
    46  - `address` / `CONSUL_HTTP_ADDR` - (Optional) DNS name and port of your Consul endpoint specified in the
    47    format `dnsname:port`. Defaults to the local agent HTTP listener.
    48  - `scheme` - (Optional) Specifies what protocol to use when talking to the given
    49    `address`, either `http` or `https`. SSL support can also be triggered
    50    by setting then environment variable `CONSUL_HTTP_SSL` to `true`.
    51  - `datacenter` - (Optional) The datacenter to use. Defaults to that of the agent.
    52  - `http_auth` / `CONSUL_HTTP_AUTH` - (Optional) HTTP Basic Authentication credentials to be used when
    53    communicating with Consul, in the format of either `user` or `user:pass`.
    54  - `gzip` - (Optional) `true` to compress the state data using gzip, or `false` (the default) to leave it uncompressed.
    55  - `lock` - (Optional) `false` to disable locking. This defaults to true, but will require session permissions with Consul and at least kv write permissions on `$path/.lock` to perform locking.
    56  - `ca_file` / `CONSUL_CACERT` - (Optional) A path to a PEM-encoded certificate authority used to verify the remote agent's certificate.
    57  - `cert_file` / `CONSUL_CLIENT_CERT` - (Optional) A path to a PEM-encoded certificate provided to the remote agent; requires use of `key_file`.
    58  - `key_file` / `CONSUL_CLIENT_KEY` - (Optional) A path to a PEM-encoded private key, required if `cert_file` is specified.