Skip to content

CICD-239 · State locking ​

Encyclopedia · Terraform and infrastructure as code · All snippets

Previous · CICD-238 · Next · CICD-240

1. Where it fits ​

  • Placement CI run step.
  • Prerequisites trusted Linux runner, Terraform CLI, reviewed IaC and a disposable state for writes.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
terraform plan -input=false -lock-timeout=5m -no-color

3. How it works ​

The lock timeout bounds the wait for another state operation. It only works with locking configured in the chosen backend.

4. Verify the result ​

Contending clients wait for the backend lock. Never disable locking as a CI retry strategy.

Validation syntax-validated (Bash parse). Status definitions.