From 8586daa0bc5f4c6e7447fe2142ebad70d8f225e1 Mon Sep 17 00:00:00 2001 From: Ilia Baryshnikov Date: Wed, 10 Jan 2024 21:44:28 +0100 Subject: [PATCH] support force-unlock for remote http backends. Fixes #28421 another one https://github.com/hashicorp/terraform/pull/28807 --- internal/backend/remote-state/http/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/backend/remote-state/http/client.go b/internal/backend/remote-state/http/client.go index afa3495488e1..c622e9cd084f 100644 --- a/internal/backend/remote-state/http/client.go +++ b/internal/backend/remote-state/http/client.go @@ -126,11 +126,20 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) { } func (c *httpClient) Unlock(id string) error { + var info statemgr.LockInfo + if c.UnlockURL == nil { return nil } - resp, err := c.httpRequest(c.UnlockMethod, c.UnlockURL, &c.jsonLockInfo, "unlock") + if err := json.Unmarshal(c.jsonLockInfo, &info); err != nil { + return err + } + + info.ID = id + jsonLockInfo := info.Marshal() + + resp, err := c.httpRequest(c.UnlockMethod, c.UnlockURL, &jsonLockInfo, "unlock") if err != nil { return err }