Scoping GitHub Actions concurrency to Terraform state instead of branches
Auto-merging Dependabot security PRs caused deploys to fail with a GCS 412 Precondition Failed error on the Terraform state lock. Each merge pushed to main and triggered a deploy that ran terraform apply against the same state object, so concurrent runs collided. The author found that the common approach of keying concurrency on workflow and branch was wrong, because the true lock is the state object. Their fix keys the concurrency group on the service and environment, which map to the GCS prefix and Terraform workspace. This lets prod and dev deploys run in parallel while still serializing deploys that share state, and cancel-in-progress is set to false to avoid killing an apply mid-flight.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in