terraform
terraform copied to clipboard
Add workspaces support to HTTP backend
Hi,
Here is an implementation of HTTP remote backend workspace handling by passing workspace information as query param.
Work was influenced by the lock implementation that pass the LockID information as query parameter on all subsequent requests.
This version passes the workspace also as query parameter to all operations if workspace is not the default one, enabling the remote HTTP endpoint to act accordingly with minimal user configuration. Workspace path handling implementation is left to the remote HTTP endpoint.
If workspaces_address
is enabled, Terraform act as if workspaces are enabled and will:
- use by default the
OPTIONS
HTTP method to list current workspaces. - use the
DELETE
HTTP method to remove a workspace.
If workspaces_address
is not enabled, workspace are disabled.
A simple backend configuration could then be:
terraform {
backend "http" {
address = "http://myrestapi.example.com/foo"
lock_address = "http://myrestapi.example.com/foo"
unlock_address = "http://myrestapi.example.com/foo"
workspaces_address = "http://myrestapi.example.com/foo"
}
}
Also, workspaces handling can be enabled on default address through the workspaces
setting.
terraform {
backend "http" {
address = "http://myrestapi.example.com/foo"
lock_address = "http://myrestapi.example.com/foo"
unlock_address = "http://myrestapi.example.com/foo"
workspaces = true
}
}
Regards,