Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workspaces support to HTTP backend #26796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lenaing
Copy link

@lenaing lenaing commented Nov 3, 2020

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,

@hashicorp-cla
Copy link

hashicorp-cla commented Nov 3, 2020

CLA assistant check
All committers have signed the CLA.

@lenaing lenaing force-pushed the backend-http-remote-workspaces branch from 636c589 to 89b7177 Compare November 3, 2020 09:49
@codecov
Copy link

codecov bot commented Nov 3, 2020

Codecov Report

Merging #26796 into master will increase coverage by 0.00%.
The diff coverage is 54.63%.

Impacted Files Coverage Δ
backend/remote-state/http/backend.go 77.90% <53.19%> (-7.25%) ⬇️
backend/remote-state/http/client.go 50.90% <56.00%> (+0.48%) ⬆️
internal/providercache/dir.go 67.34% <0.00%> (-6.13%) ⬇️
terraform/node_resource_apply_instance.go 75.78% <0.00%> (+0.78%) ⬆️
terraform/eval_diff.go 67.43% <0.00%> (+0.91%) ⬆️
dag/marshal.go 54.79% <0.00%> (+1.36%) ⬆️
terraform/node_resource_plan.go 97.16% <0.00%> (+1.88%) ⬆️

@lenaing lenaing force-pushed the backend-http-remote-workspaces branch from 2f2c782 to b686066 Compare November 3, 2020 10:05
@lenaing lenaing force-pushed the backend-http-remote-workspaces branch from b686066 to 2002e21 Compare November 3, 2020 20:36
@kalw
Copy link

kalw commented Nov 8, 2020

Hi there !

Is this PR relate to specific issues encountered with #26032 ?

@lenaing
Copy link
Author

lenaing commented Nov 8, 2020

Hello,

Yes it does. I worked on the subject prior checking if another PR was already opened... so I launched a discussion thread here about the implementation : #26797
My PR only deals with workspaces support however, not HTTP header injection if that's what your are looking for.

Regards,

Base automatically changed from master to main February 24, 2021 18:01
@lenaing lenaing force-pushed the backend-http-remote-workspaces branch from e5f4800 to 39b563b Compare January 28, 2022 09:10
@lenaing lenaing force-pushed the backend-http-remote-workspaces branch from 39b563b to a51ab9e Compare November 23, 2022 19:15
@lenaing lenaing marked this pull request as ready for review November 23, 2022 19:36
@lenaing lenaing requested a review from a team as a code owner November 23, 2022 19:36
@zeitounator
Copy link

Hello, is someone from hashicorp actually looking at this PR and related discussion?

@gmarkey
Copy link

gmarkey commented Apr 27, 2023

This would be such a powerful enhancement for Terraform; it would be great if someone from Hashicorp could take a look at the associated PR.

@hartkibo
Copy link

hartkibo commented Aug 8, 2024

this would be a really nice addition, please someone have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants