HTTP Backend
The HTTP backend stores state using REST API endpoints. This is a generic backend that works with any HTTP server implementing the required API.Implementation
Location:/internal/backend/remote-state/http/backend.go
Use Cases
- Custom state storage implementations
- Integration with existing HTTP-based systems
- Cloud-agnostic state management
- Simple state storage without additional infrastructure
Basic Configuration
Required Configuration
address
- Type: String
- Required: Yes
- Environment Variable:
TF_HTTP_ADDRESS - Description: The URL of the REST endpoint for state operations
http or https scheme.
Optional Configuration
update_method
- Type: String
- Optional: Yes
- Default:
"POST" - Environment Variable:
TF_HTTP_UPDATE_METHOD - Description: HTTP method to use when updating state
State Locking Configuration
lock_address
- Type: String
- Optional: Yes
- Environment Variable:
TF_HTTP_LOCK_ADDRESS - Description: The address of the lock REST endpoint
lock_method
- Type: String
- Optional: Yes
- Default:
"LOCK" - Environment Variable:
TF_HTTP_LOCK_METHOD - Description: HTTP method to use when locking
unlock_address
- Type: String
- Optional: Yes
- Environment Variable:
TF_HTTP_UNLOCK_ADDRESS - Description: The address of the unlock REST endpoint
unlock_method
- Type: String
- Optional: Yes
- Default:
"UNLOCK" - Environment Variable:
TF_HTTP_UNLOCK_METHOD - Description: HTTP method to use when unlocking
Authentication
HTTP Basic Authentication
TF_HTTP_USERNAMETF_HTTP_PASSWORD
TLS Configuration
Skip Certificate Verification
Custom CA Certificate
TF_HTTP_CLIENT_CA_CERTIFICATE_PEM
Provide a PEM-encoded CA certificate chain to verify the server certificate.
Mutual TLS (mTLS)
TF_HTTP_CLIENT_CERTIFICATE_PEMTF_HTTP_CLIENT_PRIVATE_KEY_PEM
Retry Configuration
retry_max
- Type: Number
- Optional: Yes
- Default:
2 - Environment Variable:
TF_HTTP_RETRY_MAX - Description: Maximum number of HTTP request retries
retry_wait_min
- Type: Number (seconds)
- Optional: Yes
- Default:
1 - Environment Variable:
TF_HTTP_RETRY_WAIT_MIN - Description: Minimum time to wait between retries
retry_wait_max
- Type: Number (seconds)
- Optional: Yes
- Default:
30 - Environment Variable:
TF_HTTP_RETRY_WAIT_MAX - Description: Maximum time to wait between retries
API Requirements
The HTTP backend expects the following API:GET (Retrieve State)
Request:- 200 OK - Returns the current state as JSON
- 404 Not Found - No state exists (treated as empty state)
POST/PUT (Update State)
Request:- 200 OK - State updated successfully
DELETE (Delete State)
Request:- 200 OK - State deleted successfully
LOCK (Lock State)
Request:- 200 OK - Lock acquired
- 409 Conflict - Lock already held (returns lock info)
UNLOCK (Unlock State)
Request:- 200 OK - Lock released
Configuration Options Summary
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
address | string | Yes | - | State REST endpoint URL |
update_method | string | No | POST | HTTP method for updates |
lock_address | string | No | - | Lock endpoint URL |
lock_method | string | No | LOCK | HTTP method for locking |
unlock_address | string | No | - | Unlock endpoint URL |
unlock_method | string | No | UNLOCK | HTTP method for unlocking |
username | string | No | - | Basic auth username |
password | string | No | - | Basic auth password |
skip_cert_verification | bool | No | false | Skip TLS verification |
retry_max | number | No | 2 | Max retry attempts |
retry_wait_min | number | No | 1 | Min retry wait (seconds) |
retry_wait_max | number | No | 30 | Max retry wait (seconds) |
client_ca_certificate_pem | string | No | - | CA certificate PEM |
client_certificate_pem | string | No | - | Client certificate PEM |
client_private_key_pem | string | No | - | Client private key PEM |
Example: GitLab HTTP Backend
Example: Custom HTTP Backend with mTLS
Limitations
- No workspace support - The HTTP backend does not support workspaces
- Custom implementation required - Server must implement the expected API
- No versioning - State versioning depends on server implementation
Best Practices
- Use HTTPS for all production endpoints
- Enable state locking to prevent concurrent modifications
- Implement authentication on the server side
- Version your API for backward compatibility
- Log all operations for audit trails
- Implement proper error handling in the server
- Use mTLS for enhanced security