2017-02-15 19:47:30 +01:00
|
|
|
|
---
|
2017-02-15 21:19:38 +01:00
|
|
|
|
layout: "backend-types"
|
|
|
|
|
page_title: "Backend Type: http"
|
|
|
|
|
sidebar_current: "docs-backends-types-standard-http"
|
2017-02-15 19:47:30 +01:00
|
|
|
|
description: |-
|
2017-02-15 21:19:38 +01:00
|
|
|
|
Terraform can store state remotely at any valid HTTP endpoint.
|
2017-02-15 19:47:30 +01:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# http
|
|
|
|
|
|
2017-08-13 18:49:49 +02:00
|
|
|
|
**Kind: Standard (with optional locking)**
|
2017-02-15 21:19:38 +01:00
|
|
|
|
|
2017-02-15 19:47:30 +01:00
|
|
|
|
Stores the state using a simple [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) client.
|
|
|
|
|
|
2017-08-20 14:59:34 +02:00
|
|
|
|
State will be fetched via GET, updated via POST, and purged with DELETE. The method used for updating is configurable.
|
2017-02-15 19:47:30 +01:00
|
|
|
|
|
2017-08-20 14:59:34 +02:00
|
|
|
|
When locking support is enabled it will use LOCK and UNLOCK requests providing the lock info in the body. The endpoint should
|
|
|
|
|
return a 423: Locked or 409: Conflict with the holding lock info when it's already taken, 200: OK for success. Any other status
|
|
|
|
|
will be considered an error. The ID of the holding lock info will be added as a query parameter to state updates requests.
|
2017-08-13 18:49:49 +02:00
|
|
|
|
|
2017-02-15 19:47:30 +01:00
|
|
|
|
## Example Usage
|
|
|
|
|
|
2017-04-05 17:29:27 +02:00
|
|
|
|
```hcl
|
2017-02-15 21:19:38 +01:00
|
|
|
|
terraform {
|
|
|
|
|
backend "http" {
|
2017-08-20 14:59:34 +02:00
|
|
|
|
address = "http://myrest.api.com/foo"
|
|
|
|
|
lock_address = "http://myrest.api.com/foo"
|
|
|
|
|
unlock_address = "http://myrest.api.com/foo"
|
2017-02-15 21:19:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-15 19:47:30 +01:00
|
|
|
|
```
|
|
|
|
|
|
2020-02-19 01:40:14 +01:00
|
|
|
|
## Data Source Configuration
|
2017-02-15 19:47:30 +01:00
|
|
|
|
|
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 = "http"
|
2018-10-29 17:22:21 +01:00
|
|
|
|
config = {
|
2017-04-05 17:29:27 +02:00
|
|
|
|
address = "http://my.rest.api.com"
|
|
|
|
|
}
|
2017-02-15 19:47:30 +01:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Configuration variables
|
|
|
|
|
|
|
|
|
|
The following configuration options are supported:
|
|
|
|
|
|
|
|
|
|
* `address` - (Required) The address of the REST endpoint
|
2017-08-20 14:59:34 +02:00
|
|
|
|
* `update_method` - (Optional) HTTP method to use when updating state.
|
|
|
|
|
Defaults to `POST`.
|
|
|
|
|
* `lock_address` - (Optional) The address of the lock REST endpoint.
|
|
|
|
|
Defaults to disabled.
|
|
|
|
|
* `lock_method` - (Optional) The HTTP method to use when locking.
|
|
|
|
|
Defaults to `LOCK`.
|
|
|
|
|
* `unlock_address` - (Optional) The address of the unlock REST endpoint.
|
|
|
|
|
Defaults to disabled.
|
|
|
|
|
* `unlock_method` - (Optional) The HTTP method to use when unlocking.
|
|
|
|
|
Defaults to `UNLOCK`.
|
2017-02-15 19:47:30 +01:00
|
|
|
|
* `username` - (Optional) The username for HTTP basic authentication
|
|
|
|
|
* `password` - (Optional) The password for HTTP basic authentication
|
|
|
|
|
* `skip_cert_verification` - (Optional) Whether to skip TLS verification.
|
|
|
|
|
Defaults to `false`.
|
2019-06-05 22:12:07 +02:00
|
|
|
|
* `retry_max` – (Optional) The number of HTTP request retries. Defaults to `2`.
|
|
|
|
|
* `retry_wait_min` – (Optional) The minimum time in seconds to wait between HTTP request attempts.
|
|
|
|
|
Defaults to `1`.
|
|
|
|
|
* `retry_wait_max` – (Optional) The maximum time in seconds to wait between HTTP request attempts.
|
|
|
|
|
Defaults to `30`.
|