2017-02-15 19:47:30 +01:00
|
|
|
---
|
2017-02-15 21:19:38 +01:00
|
|
|
layout: "backend-types"
|
|
|
|
page_title: "Backend Type: consul"
|
|
|
|
sidebar_current: "docs-backends-types-standard-consul"
|
2017-02-15 19:47:30 +01:00
|
|
|
description: |-
|
2017-02-15 21:19:38 +01:00
|
|
|
Terraform can store state in Consul.
|
2017-02-15 19:47:30 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
# consul
|
|
|
|
|
2017-02-15 21:19:38 +01:00
|
|
|
**Kind: Standard (with locking)**
|
|
|
|
|
2017-02-15 19:47:30 +01:00
|
|
|
Stores the state in the [Consul](https://www.consul.io/) KV store at a given path.
|
|
|
|
|
2017-02-15 21:19:38 +01:00
|
|
|
This backend supports [state locking](/docs/state/locking.html).
|
2017-02-15 19:47:30 +01:00
|
|
|
|
2017-02-15 21:19:38 +01:00
|
|
|
## Example Configuration
|
2017-02-15 19:47:30 +01:00
|
|
|
|
2017-04-05 17:29:27 +02:00
|
|
|
```hcl
|
2017-02-15 21:19:38 +01:00
|
|
|
terraform {
|
|
|
|
backend "consul" {
|
|
|
|
address = "demo.consul.io"
|
2018-06-22 19:18:27 +02:00
|
|
|
scheme = "https"
|
2017-02-15 21:19:38 +01:00
|
|
|
path = "full/path"
|
|
|
|
}
|
|
|
|
}
|
2017-02-15 19:47:30 +01:00
|
|
|
```
|
|
|
|
|
2017-02-15 21:19:38 +01:00
|
|
|
Note that for the access credentials we recommend using a
|
|
|
|
[partial configuration](/docs/backends/config.html).
|
|
|
|
|
2017-02-15 19:47:30 +01:00
|
|
|
## Example Referencing
|
|
|
|
|
2017-04-05 17:29:27 +02:00
|
|
|
```hcl
|
2017-02-15 19:47:30 +01:00
|
|
|
data "terraform_remote_state" "foo" {
|
2017-04-05 17:29:27 +02:00
|
|
|
backend = "consul"
|
2018-10-29 17:22:21 +01:00
|
|
|
config = {
|
2017-04-05 17:29:27 +02:00
|
|
|
path = "full/path"
|
|
|
|
}
|
2017-02-15 19:47:30 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration variables
|
|
|
|
|
|
|
|
The following configuration options / environment variables are supported:
|
|
|
|
|
|
|
|
* `path` - (Required) Path in the Consul KV store
|
|
|
|
* `access_token` / `CONSUL_HTTP_TOKEN` - (Required) Access token
|
|
|
|
* `address` / `CONSUL_HTTP_ADDR` - (Optional) DNS name and port of your Consul endpoint specified in the
|
|
|
|
format `dnsname:port`. Defaults to the local agent HTTP listener.
|
|
|
|
* `scheme` - (Optional) Specifies what protocol to use when talking to the given
|
|
|
|
`address`, either `http` or `https`. SSL support can also be triggered
|
|
|
|
by setting then environment variable `CONSUL_HTTP_SSL` to `true`.
|
|
|
|
* `datacenter` - (Optional) The datacenter to use. Defaults to that of the agent.
|
|
|
|
* `http_auth` / `CONSUL_HTTP_AUTH` - (Optional) HTTP Basic Authentication credentials to be used when
|
|
|
|
communicating with Consul, in the format of either `user` or `user:pass`.
|
2017-03-13 08:17:33 +01:00
|
|
|
* `gzip` - (Optional) `true` to compress the state data using gzip, or `false` (the default) to leave it uncompressed.
|
2017-03-15 01:28:42 +01:00
|
|
|
* `lock` - (Optional) `false` to disable locking. This defaults to true, but will require session permissions with Consul to perform locking.
|
2017-08-23 18:47:21 +02:00
|
|
|
* `ca_file` / `CONSUL_CAFILE` - (Optional) A path to a PEM-encoded certificate authority used to verify the remote agent's certificate.
|
|
|
|
* `cert_file` / `CONSUL_CLIENT_CERT` - (Optional) A path to a PEM-encoded certificate provided to the remote agent; requires use of `key_file`.
|
|
|
|
* `key_file` / `CONSUL_CLIENT_KEY` - (Optional) A path to a PEM-encoded private key, required if `cert_file` is specified.
|