Reputation: 57
I'm wondering if someone could work with the Terraform lock state file on the GCS via Datastore present in GCP as done in AWS with the S3 backend and DynamoDB table.
If so, please give an example on how to do it.
Upvotes: 1
Views: 1232
Reputation: 56987
You don't need to use anything else for state locking when using GCS because the consistency model is stronger than S3.
S3 has eventual consistency on modifications to files so Terraform can't rely on that for locking and has to rely on DynamoDB instead (which can have stronger consistency guarantees). GCS is strongly consistent on updates so Terraform just uses that directly.
To test this you can set your backend up to use GCS, run terraform apply
but leave it on the approval prompt and then, in another terminal, run terraform plan
against the same state file. You will see that the state file is locked by the terraform apply
action.
Upvotes: 6