Putnik
Putnik

Reputation: 6854

Terraform: Failed to unlock state: failed to retrieve lock info: unexpected end of JSON input

terraform plan was aborted, and now it cannot acquire the state lock. I'm trying to release it manually but get error:

terraform force-unlock -force xxx-xxx-xx-dddd

Failed to unlock state: failed to retrieve lock info:
unexpected end of JSON input

The state file looks complete and passes json syntax validation successfully.

How to fix that?

Upvotes: 15

Views: 16676

Answers (3)

hbceylan
hbceylan

Reputation: 1282

I had the same issue. In my case, there were more than 1 .tfstate files in the working directory. This was causing the problem.

1- Ensure you have only 1 .tfstate file in the working directory

2- Ensure .tfstate file is valid.

Upvotes: 1

user1810084
user1810084

Reputation: 39

I had to switch to the right workspace and issue the command terraform force-unlcok -force to get away with the issue.

Upvotes: 0

Putnik
Putnik

Reputation: 6854

Solution: double-check you're in correct terraform workspace.

Upvotes: 37

Related Questions