Terraform cloud - Error acquiring state lock

I’m just starting with Terraform, and have setup a Terraform Cloud account (Free version) so that I can use that to manage the remote state. But, when I try and run the plan, I get the following error message:

> terraform.exe init                                             
Initializing the backend...                                                               
                                                                                          
Error: Error locking destination state: Error acquiring the state lock: resource not found
                                                                                          
Terraform acquires a state lock to protect the state from being written                   
by multiple users at the same time. Please resolve the issue above and try                
again. For most commands, you can disable locking with the "-lock=false"                  
flag, but this is not recommended.                                                        

It works the first time (and I can see the workspace has been created in Terraform Cloud), but I can’t run any commands. Even a simple plan that creates a new Azure resource group fails with the above error.

I am using a user-level token - do I need to use a Team token instead?

Terraform v0.12.3 on Windows x64

For reference, using a Team token (rather than a user level token) worked correctly.

1 Like