Manual Lock of Terraform State

We are using terraform for our iac deployments to AWS. And due to the specifics of one of our deployments, and to avoid certain edge cases, we need to prevent concurrent execution of the pipeline on the master branch,

To do that I’m thinking to create a dummy state file that represents the “state” of the pipeline. And to lock it when a deployment starts and to unlock it on completion. A deployment will then only run if that state file is unlocked. I’ve tried locking with curl:

curl -XPOST --header 'private-token: <TOKEN>' "<STATEFILE_URL>/lock"

But that fails with 500. Can someone point out what I’m doing wrong here? Or should I use a different approach for locking pipelines in this way?



if you want to limit the concurrency of CI/CD pipelines, running in parallel by default, you can use resource groups.

  stage: deploy
  script: echo "TF apply runs here"
  environment: production
  resource_group: production


@davR I have the same problem. Do you solve this project?
curl -X POST --header "PRIVATE-TOKEN:<TOKEN>" "<STATEFILE_URL>/lock" fails with 500 internal server error
curl -X DELETE --header "PRIVATE-TOKEN:<TOKEN>" "<STATEFILE_URL>/lock" works fine.