-
-
Save kavehmz/b7e165e7a5ff7ca27910df5f1fbc5f2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding lock mechanism to GCS remote backend by suing pubsub Topics. | |
Concept is imilar to how we create/delete lock file to acquirs/release lock. | |
We are using remote state-file in our team.We need this in our team to be able to work in a safer way. Our team is small but still this simple change can improve out ability to work together. | |
Code changes is small. | |
```hcl | |
terraform { | |
backend "gcs" { | |
bucket = "tf-state-prod" | |
path = "path/terraform.tfstate" | |
project = "myproject" | |
lockTopic = "remote_lock" | |
} | |
} | |
``` | |
Only addition will be __lock_topic__. As far as I understand the change is backward compatible and won't break any existing setup. If this change get accepted I will also work/help on moving GCP out of legacy so this change won't cause any extra burden on your team. | |
I ran the tests to make sure they are all green. All pass locally against my dev project in google cloud. | |
Also I ran a separate code against pubsub to check if __create__ can be used as lock mechanism. As far as I can tell it is a serial action and usable for lock. | |
Adding this change will help me greatly and I am hoping that this method might be useful for others too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment