When running any Terraform commands (
plan, etc) from a different server, the following error is thrown:-
Error: google: could not find default credentials.
for more information.
on line 0:
(source code not available)
One recommended way is to set up a service account by following the instruction from the above link.
Another way, for developement purpose, is to install Google Cloud SDK and run the following
gcloud command, which will generate an Application Default Credentials (ADC) JSON file based on your user account and store it in a location where the SDK can find it automatically:-
gcloud auth application-default login
terraform plan, the following error is thrown:-
Acquiring state lock. This may take a few moments...
Error: Error locking state: Error acquiring the state lock: writing "gs://my/bucket/terraform.tfstate/default.tflock" failed: googleapi: Error 412: Precondition Failed, conditionNotMet
Operation: migration destination state
Created: 2019-10-30 12:44:36.410366 +0000 UTC
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.
One way is to disable locking by passing
However, if you are sure the lock isn’t properly released, to perform a force unlock, run this command:
terraform force-unlock [LOCK_ID]
In this case…
terraform force-unlock 1234567890