Reputation: 67
while running terraform plan i did a CTRL C on a windows computer and now when i try to run terraform plan again i get
Error: Error loading state: Failed to read state file: The state file could not be read: read terraform.tfstate: The process cannot access the file because another process has locked a portion of the file.
I tried
terraform force-unlock id
but that gives me
Local state cannot be unlocked by another process
I am kind of stuck and cannot move forward
Much appreciated if someone can please assist.
Regards, KKR
Upvotes: 2
Views: 22114
Reputation: 378
I faced this issue when trying to run a Terraform Init
and Terraform Plan
from two different instances of AzureCLI task (a similar AWS task in your case). Move all the terraform commands to a single instance of the task and that should fix the issue.
Upvotes: 0
Reputation: 2555
Did you save the state file in s3 or local? If it is from remote, try to delete that state file first and retry. If it is local process, you will need to kill the process and delete the state file from your local folder .terraform/terraform.tfstate
Upvotes: 1