How do you handle state locking when the pipeline runs apply on merge? We have the plan step working fine on the PR, but the merge job fails with a state lock error because the plan process hasn’t fully released the lock yet. The GitHub Actions workflow uses the standard hashicorp/setup-terraform action. Is there a specific timeout setting we need to adjust in the provider block or is this a race condition in the CI runner?
State locking in Terraform is usually a backend issue, not a provider timeout. You’ll want to ensure your GitHub Actions workflow uses a mutex or a dedicated lock file step before the apply runs. It’s a common race condition in CI pipelines.
Try adding a hashicorp/consul-api-action or using the tflock action to manage the lock explicitly. This prevents the plan and apply jobs from stepping on each other’s toes during the merge window.