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.
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)- A10% (2)
- B86% (18)
- C5% (1)
Why each option
The terraform force-unlock subcommand is used to manually release a stuck or orphaned lock on a Terraform state file.
'Unlock' is not a valid Terraform subcommand; the correct command name is force-unlock.
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.
Removing a state lock is absolutely possible using terraform force-unlock, so this option is factually incorrect.
'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
Community Discussion
No community discussion yet for this question.