2017-09-09 00:40:05 +02:00
|
|
|
---
|
2020-08-15 03:51:06 +02:00
|
|
|
layout: "language"
|
2017-09-09 00:40:05 +02:00
|
|
|
page_title: "Backend Type: etcdv3"
|
|
|
|
sidebar_current: "docs-backends-types-standard-etcdv3"
|
|
|
|
description: |-
|
|
|
|
Terraform can store state remotely in etcd 3.x.
|
|
|
|
---
|
|
|
|
|
|
|
|
# etcdv3
|
|
|
|
|
|
|
|
**Kind: Standard (with locking)**
|
|
|
|
|
2018-05-23 00:19:48 +02:00
|
|
|
Stores the state in the [etcd](https://coreos.com/etcd/) KV store with a given prefix.
|
2017-09-09 00:40:05 +02:00
|
|
|
|
2021-01-15 23:13:53 +01:00
|
|
|
This backend supports [state locking](/docs/language/state/locking.html).
|
2017-09-09 00:40:05 +02:00
|
|
|
|
|
|
|
## Example Configuration
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
terraform {
|
|
|
|
backend "etcdv3" {
|
|
|
|
endpoints = ["etcd-1:2379", "etcd-2:2379", "etcd-3:2379"]
|
|
|
|
lock = true
|
|
|
|
prefix = "terraform-state/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that for the access credentials we recommend using a
|
2021-01-16 00:41:43 +01:00
|
|
|
[partial configuration](/docs/language/settings/backends/configuration.html#partial-configuration).
|
2017-09-09 00:40:05 +02:00
|
|
|
|
2020-02-19 01:40:14 +01:00
|
|
|
## Data Source Configuration
|
2017-09-09 00:40:05 +02:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
data "terraform_remote_state" "foo" {
|
|
|
|
backend = "etcdv3"
|
2018-10-29 17:22:21 +01:00
|
|
|
config = {
|
2017-09-09 00:40:05 +02:00
|
|
|
endpoints = ["etcd-1:2379", "etcd-2:2379", "etcd-3:2379"]
|
|
|
|
lock = true
|
|
|
|
prefix = "terraform-state/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration variables
|
|
|
|
|
|
|
|
The following configuration options / environment variables are supported:
|
|
|
|
|
|
|
|
* `endpoints` - (Required) The list of 'etcd' endpoints which to connect to.
|
2017-09-09 00:41:27 +02:00
|
|
|
* `username` / `ETCDV3_USERNAME` - (Optional) Username used to connect to the etcd cluster.
|
|
|
|
* `password` / `ETCDV3_PASSWORD` - (Optional) Password used to connect to the etcd cluster.
|
2017-09-09 00:40:05 +02:00
|
|
|
* `prefix` - (Optional) An optional prefix to be added to keys when to storing state in etcd. Defaults to `""`.
|
|
|
|
* `lock` - (Optional) Whether to lock state access. Defaults to `true`.
|
2017-09-09 09:03:59 +02:00
|
|
|
* `cacert_path` - (Optional) The path to a PEM-encoded CA bundle with which to verify certificates of TLS-enabled etcd servers.
|
|
|
|
* `cert_path` - (Optional) The path to a PEM-encoded certificate to provide to etcd for secure client identification.
|
|
|
|
* `key_path` - (Optional) The path to a PEM-encoded key to provide to etcd for secure client identification.
|