Skip to content

Commit f2ffff3

Browse files
committed
docs: Create new section for remote state backends
1 parent e8006f1 commit f2ffff3

12 files changed

Lines changed: 375 additions & 61 deletions

File tree

website/source/assets/stylesheets/_docs.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ body.layout-vsphere,
3535
body.layout-docs,
3636
body.layout-downloads,
3737
body.layout-inner,
38+
body.layout-remotestate,
3839
body.layout-terraform,
3940
body.layout-intro{
4041
background: $light-black image-url('sidebar-wire.png') left 62px no-repeat;

website/source/docs/commands/remote-config.html.markdown

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,70 +40,16 @@ below this section for more details.
4040
When remote storage is disabled, the existing remote state is migrated
4141
to a local file. This defaults to the `-state` path during restore.
4242

43-
The following backends are supported:
44-
45-
* Atlas - Stores the state in Atlas. Requires the `name` and `access_token`
46-
variables. The `address` variable can optionally be provided.
47-
48-
* Consul - Stores the state in the KV store at a given path. Requires the
49-
`path` variable. Supports the `CONSUL_HTTP_TOKEN` environment variable
50-
for specifying access credentials, or the `access_token` variable may
51-
be provided, but this is not recommended since it would be included in
52-
cleartext inside the persisted, shard state. Other supported parameters
53-
include:
54-
* `address` - DNS name and port of your Consul endpoint specified in the
55-
format `dnsname:port`. Defaults to the local agent HTTP listener. This
56-
may also be specified using the `CONSUL_HTTP_ADDR` environment variable.
57-
* `scheme` - Specifies what protocol to use when talking to the given
58-
`address`, either `http` or `https`. SSL support can also be triggered
59-
by setting then environment variable `CONSUL_HTTP_SSL` to `true`.
60-
* `http_auth` - HTTP Basic Authentication credentials to be used when
61-
communicating with Consul, in the format of either `user` or `user:pass`.
62-
This may also be specified using the `CONSUL_HTTP_AUTH` environment
63-
variable.
64-
65-
* Etcd - Stores the state in etcd at a given path.
66-
Requires the `path` and `endpoints` variables. The `username` and `password`
67-
variables can optionally be provided. `endpoints` is assumed to be a
68-
space-separated list of etcd endpoints.
69-
70-
* S3 - Stores the state as a given key in a given bucket on Amazon S3.
71-
Requires the `bucket` and `key` variables. Supports and honors the standard
72-
AWS environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
73-
`AWS_S3_ENDPOINT` and `AWS_DEFAULT_REGION`. These can optionally be provided
74-
as parameters in the `access_key`, `secret_key`, `endpoint` and `region`
75-
variables respectively, but passing credentials this way is not recommended
76-
since they will be included in cleartext inside the persisted state.
77-
Other supported parameters include:
78-
* `bucket` - the name of the S3 bucket
79-
* `key` - path where to place/look for state file inside the bucket
80-
* `encrypt` - whether to enable [server side encryption](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html)
81-
of the state file
82-
* `acl` - [Canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl)
83-
to be applied to the state file.
84-
85-
* Artifactory - Stores the state as an artifact in a given repository in
86-
Artifactory. Requires the `url`, `username`, `password`, `repo` and `subpath`
87-
variables. Generic HTTP repositories are supported, and state from different
88-
configurations may be kept at different subpaths within the repository. The URL
89-
must include the path to the Artifactory installation - it will likely end in
90-
`/artifactory`. Alternately the following environment variables can be used in
91-
place of hard-coded values:
92-
* `ARTIFACTORY_USERNAME`
93-
* `ARTIFACTORY_PASSWORD`
94-
* `ARTIFACTORY_URL` (note that this is the base url to artifactory not the full repo and subpath)
95-
96-
97-
* HTTP - Stores the state using a simple REST client. State will be fetched
98-
via GET, updated via POST, and purged with DELETE. Requires the `address` variable.
43+
Supported storage backends and supported features of those
44+
are documented in the [Remote State](/docs/state/remote/index.html) section.
9945

10046
The command-line flags are all optional. The list of available flags are:
10147

102-
* `-backend=Atlas` - The remote backend to use. Must be one of the above
48+
* `-backend=Atlas` - The remote backend to use. Must be one of the
10349
supported backends.
10450

10551
* `-backend-config="k=v"` - Specify a configuration variable for a backend.
106-
This is how you set the required variables for the backends above.
52+
This is how you set the required variables for the backend.
10753

10854
* `-backup=path` - Path to backup the existing state file before
10955
modifying. Defaults to the "-state" path with ".backup" extension.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: artifactory"
4+
sidebar_current: "docs-state-remote-artifactory"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# artifactory
10+
11+
Stores the state as an artifact in a given repository in [Artifactory](https://www.jfrog.com/artifactory/).
12+
13+
Generic HTTP repositories are supported, and state from different
14+
configurations may be kept at different subpaths within the repository.
15+
16+
-> **Note:** The URL must include the path to the Artifactory installation.
17+
It will likely end in `/artifactory`.
18+
19+
## Example Usage
20+
21+
```
22+
terraform remote config \
23+
-backend=artifactory \
24+
-backend-config="username=SheldonCooper" \
25+
-backend-config="password=AmyFarrahFowler" \
26+
-backend-config="url=https://custom.artifactoryonline.com/artifactory" \
27+
-backend-config="repo=foo" \
28+
-backend-config="subpath=terraform-bar"
29+
```
30+
31+
## Example Referencing
32+
33+
```
34+
resource "terraform_remote_state" "foo" {
35+
backend = "artifactory"
36+
config {
37+
username = "SheldonCooper"
38+
password = "AmyFarrahFowler"
39+
url = "https://custom.artifactoryonline.com/artifactory"
40+
repo = "foo"
41+
subpath = "terraform-bar"
42+
}
43+
}
44+
```
45+
46+
## Configuration variables
47+
48+
The following configuration options / environment variables are supported:
49+
50+
* `username` / `ARTIFACTORY_USERNAME` (Required) - The username
51+
* `password` / `ARTIFACTORY_PASSWORD` (Required) - The password
52+
* `url` / `ARTIFACTORY_URL` (Required) - The URL. Note that this is the base url to artifactory not the full repo and subpath.
53+
* `repo` (Required) - The repository name
54+
* `subpath` (Required) - Path within the repository
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: atlas"
4+
sidebar_current: "docs-state-remote-atlas"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# atlas
10+
11+
Stores the state in [Atlas](https://atlas.hashicorp.com/).
12+
13+
You can create a new environment in the [Environments section](https://atlas.hashicorp.com/environments)
14+
and generate new token in the [Tokens page](https://atlas.hashicorp.com/settings/tokens) under Settings.
15+
16+
## Example Usage
17+
18+
```
19+
terraform remote config \
20+
-backend=atlas \
21+
-backend-config="name=bigbang/example" \
22+
-backend-config="access_token=X2iTFefU5aWOjg.atlasv1.YaDa" \
23+
```
24+
25+
## Example Referencing
26+
27+
```
28+
resource "terraform_remote_state" "foo" {
29+
backend = "atlas"
30+
config {
31+
name = "bigbang/example"
32+
access_token = "X2iTFefU5aWOjg.atlasv1.YaDa"
33+
}
34+
}
35+
```
36+
37+
## Configuration variables
38+
39+
The following configuration options / environment variables are supported:
40+
41+
* `name` - (Required) Full name of the environment (`<username>/<name>`)
42+
* `access_token` / `ATLAS_TOKEN` - (Required) Atlas API token
43+
* `address` - (Optional) Address to alternative Atlas location (Atlas Enterprise endpoint)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: consul"
4+
sidebar_current: "docs-state-remote-consul"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# consul
10+
11+
Stores the state in the [Consul](https://www.consul.io/) KV store at a given path.
12+
13+
-> **Note:** Specifying `access_token` directly makes it included in
14+
cleartext inside the persisted, shard state.
15+
Use of the environment variable `CONSUL_HTTP_TOKEN` is recommended.
16+
17+
## Example Usage
18+
19+
```
20+
terraform remote config \
21+
-backend=consul \
22+
-backend-config="path=full/path"
23+
```
24+
25+
## Example Referencing
26+
27+
```
28+
resource "terraform_remote_state" "foo" {
29+
backend = "consul"
30+
config {
31+
path = "full/path"
32+
}
33+
}
34+
```
35+
36+
## Configuration variables
37+
38+
The following configuration options / environment variables are supported:
39+
40+
* `path` - (Required) Path in the Consul KV store
41+
* `access_token` / `CONSUL_HTTP_TOKEN` - (Required) Access token
42+
* `address` / `CONSUL_HTTP_ADDR` - (Optional) DNS name and port of your Consul endpoint specified in the
43+
format `dnsname:port`. Defaults to the local agent HTTP listener.
44+
* `scheme` - (Optional) Specifies what protocol to use when talking to the given
45+
`address`, either `http` or `https`. SSL support can also be triggered
46+
by setting then environment variable `CONSUL_HTTP_SSL` to `true`.
47+
* `http_auth` / `CONSUL_HTTP_AUTH` - (Optional) HTTP Basic Authentication credentials to be used when
48+
communicating with Consul, in the format of either `user` or `user:pass`.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: etcd"
4+
sidebar_current: "docs-state-remote-etcd"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# etcd
10+
11+
Stores the state in [etcd](https://coreos.com/etcd/) at a given path.
12+
13+
## Example Usage
14+
15+
```
16+
terraform remote config \
17+
-backend=etcd \
18+
-backend-config="path=path/to/terraform.tfstate" \
19+
-backend-config="endpoints=http://one:4001 http://two:4001"
20+
```
21+
22+
## Example Referencing
23+
24+
```
25+
resource "terraform_remote_state" "foo" {
26+
backend = "etcd"
27+
config {
28+
path = "path/to/terraform.tfstate"
29+
endpoints = "http://one:4001 http://two:4001"
30+
}
31+
}
32+
```
33+
34+
## Configuration variables
35+
36+
The following configuration options are supported:
37+
38+
* `path` - (Required) The path where to store the state
39+
* `endpoints` - (Required) A space-separated list of the etcd endpoints
40+
* `username` - (Optional) The username
41+
* `password` - (Optional) The password
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: http"
4+
sidebar_current: "docs-state-remote-http"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# http
10+
11+
Stores the state using a simple [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) client.
12+
13+
State will be fetched via GET, updated via POST, and purged with DELETE.
14+
15+
## Example Usage
16+
17+
```
18+
terraform remote config \
19+
-backend=http \
20+
-backend-config="address=http://my.rest.api.com"
21+
```
22+
23+
## Example Referencing
24+
25+
```
26+
resource "terraform_remote_state" "foo" {
27+
backend = "http"
28+
config {
29+
address = "http://my.rest.api.com"
30+
}
31+
}
32+
```
33+
34+
## Configuration variables
35+
36+
The following configuration options are supported:
37+
38+
* `address` - (Required) The address of the REST endpoint
39+
* `skip_cert_verification` - (Optional) Whether to skip TLS verification.
40+
Defaults to `false`.

website/source/docs/state/remote.html.md renamed to website/source/docs/state/remote/index.html.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
layout: "docs"
2+
layout: "remotestate"
33
page_title: "Remote State"
4-
sidebar_current: "docs-state-remote"
4+
sidebar_current: "docs-state-remote_index"
55
description: |-
66
Terraform can store the state remotely, making it easier to version and work with in a team.
77
---
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: "remotestate"
3+
page_title: "Remote State Backend: s3"
4+
sidebar_current: "docs-state-remote-s3"
5+
description: |-
6+
Terraform can store the state remotely, making it easier to version and work with in a team.
7+
---
8+
9+
# s3
10+
11+
Stores the state as a given key in a given bucket on [Amazon S3](https://aws.amazon.com/s3/).
12+
13+
-> **Note:** Passing credentials directly via config options will
14+
make them included in cleartext inside the persisted state.
15+
Use of environment variables or config file is recommended.
16+
17+
## Example Usage
18+
19+
```
20+
terraform remote config \
21+
-backend=s3 \
22+
-backend-config="bucket=terraform-state-prod" \
23+
-backend-config="key=network/terraform.tfstate" \
24+
-backend-config="region=us-east-1"
25+
```
26+
27+
## Example Referencing
28+
29+
```
30+
resource "terraform_remote_state" "foo" {
31+
backend = "s3"
32+
config {
33+
bucket = "terraform-state-prod"
34+
key = "network/terraform.tfstate"
35+
region = "us-east-1"
36+
}
37+
}
38+
```
39+
40+
## Configuration variables
41+
42+
The following configuration options / environment variables are supported:
43+
44+
* `bucket` - (Required) The name of the S3 bucket
45+
* `key` - (Required) The path where to place/look for state file inside the bucket
46+
* `region` / `AWS_DEFAULT_REGION` - (Optional) The region of the S3 bucket
47+
* `endpoint` / `AWS_S3_ENDPOINT` - (Optional) A custom endpoint for the S3 API
48+
* `encrypt` - (Optional) Whether to enable [server side encryption](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html)
49+
of the state file
50+
* `acl` - [Canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl)
51+
to be applied to the state file.
52+
* `access_key` / `AWS_ACCESS_KEY_ID` - (Optional) AWS access key
53+
* `secret_key` / `AWS_SECRET_ACCESS_KEY` - (Optional) AWS secret key

0 commit comments

Comments
 (0)