ExamGecko
Question list
Search
Search

Question 138 - Terraform Associate 003 discussion

Report
Export

When should you use the force-unlock command?

A.
You have a high priority change
Answers
A.
You have a high priority change
B.
Automatic unlocking failed
Answers
B.
Automatic unlocking failed
C.
apply failed due to a state lock
Answers
C.
apply failed due to a state lock
D.
You see a status message that you cannot acquire the lock
Answers
D.
You see a status message that you cannot acquire the lock
Suggested answer: B

Explanation:

You should use the force-unlock command when automatic unlocking failed. Terraform will lock your state for all operations that could write state, such as plan, apply, or destroy. This prevents others from acquiring the lock and potentially corrupting your state. State locking happens automatically on all operations that could write state and you won't see any message that it is happening. If state locking fails, Terraform will not continue. You can disable state locking for most commands with the -lock flag but it is not recommended. If acquiring the lock is taking longer than expected, Terraform will output a status message. If Terraform doesn't output a message, state locking is still occurring if your backend supports it. Terraform has a force-unlock command to manually unlock the state if unlocking failed. Be very careful with this command. If you unlock the state when someone else is holding the lock it could cause multiple writers. Force unlock should only be used to unlock your own lock in the situation where automatic unlocking failed. To protect you, the force-unlock command requires a unique lock ID. Terraform will output this lock ID if unlocking fails. This lock ID acts as a nonce, ensuring that locks and unlocks target the correct lock. The other situations are not valid reasons to use the force-unlock command. You should not use the force-unlock command if you have a high priority change, if apply failed due to a state lock, or if you see a status message that you cannot acquire the lock. These situations indicate that someone else is holding the lock and you should wait for them to finish their operation or contact them to resolve the issue. Using the force-unlock command in these cases could result in data loss or inconsistency.Reference= [State Locking], [Command: force-unlock]

asked 18/09/2024
Christian Andrew TANAP
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first