nerdexam
HashiCorp

TA-002-P · Question #292

Which of the following terraform subcommands could be used to remove the lock on the state for the current configuration?

The correct answer is B. force-unlock. The terraform force-unlock subcommand is used to manually release a stuck or orphaned lock on a Terraform state file.

Implement and maintain state

Question

Which of the following terraform subcommands could be used to remove the lock on the state for the current configuration?

Options

  • AUnlock
  • Bforce-unlock
  • CRemoving the lock on a state file is not possible
  • Dstate-unlock

How the community answered

(21 responses)
  • A
    10% (2)
  • B
    86% (18)
  • C
    5% (1)

Why each option

The terraform force-unlock subcommand is used to manually release a stuck or orphaned lock on a Terraform state file.

AUnlock

'Unlock' is not a valid Terraform subcommand; the correct command name is force-unlock.

Bforce-unlockCorrect

terraform force-unlock removes a lock on the state for the current configuration by accepting the lock ID as a required argument. This command is used when a previous operation failed ungracefully and left an unreleased lock, which would otherwise block all subsequent Terraform operations on that state.

CRemoving the lock on a state file is not possible

Removing a state lock is absolutely possible using terraform force-unlock, so this option is factually incorrect.

Dstate-unlock

'state-unlock' does not exist as a Terraform CLI subcommand; no such command is part of the Terraform CLI.

Concept tested: Terraform state locking and force-unlock command usage

Source: https://developer.hashicorp.com/terraform/cli/commands/force-unlock

Topics

#terraform CLI#state management#state locking#force-unlock

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice