Skip to content

terraform force-unlock does not work with remote http backends #28421

Open
@loafoe

Description

@loafoe

Terraform Version

v0.15.0

Terraform Configuration Files

terraform {
  backend "http" {
    address        = "https://tfstate.xxx/project"
    lock_address   = "https://tfstate.xxx/project"
    unlock_address = "https://tfstate.xxx/project"
  }
}

Debug Output

terraform force-unlock uuid-here
Do you really want to force-unlock?
  Terraform will remove the lock on the remote state.
  This will allow local Terraform commands to modify this state, even though it
  may be still be in use. Only 'yes' will be accepted to confirm.

  Enter a value: yes

Failed to unlock state: Unexpected HTTP response code 423

Expected Behaviour

Terraform unlocks the remote state with ID uuid-here

Actual Behaviour

Terraform sends an unlock request with an EMPTY body (ignoring the ID passed on the command line)

Additional Context

Looking at the implementation of the http Unlock call:

func (c *httpClient) Unlock(id string) error {

The id is never used and the existing lockInfo data is sent, which works fine in the happy flow of things but when trying to force-unlock from the command line it results in Terraform sending an unlock requests with an empty body leaving the remote http backend confused as to what to do.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions