Terraform plan - wait for lock to be released

I’ve integrated Terraform usage to Bamboo. I have a modular application where all pieces run under the same state.

In cases where multiple modules have changes and automatic deployment is triggered, terraform plan fails one of them since the state is locked.

Question is, can I wait for the state lock to be released instead of failing the deployment alltogether?

I’m using Terraform Cloud remote backend for state storage.

1 Like

add -lock-timeout=5m to your terraform plan command for both the pipelines. Let say pipeline 1 has locked the state, the other pipeline will keep checking for the release (for 5 minutes) without breaking the pipeline. Once pipeline 1 releases the lock, the 2nd pipeline will pick up immediately. :wink:

2 Likes