Skip to content

Allow Teraform state deletion with a CI Job Token (maintainer)

What does this MR do and why?

This change allows to delete Teraform state from CI with the $CI_JOB_TOKEN. Requires maintainer permissions. Fixes: #375242

How to set up and validate locally

Tested locally with a repo in a gdk setup.

.gitlab-ci.yml

include:
  template: Terraform.latest.gitlab-ci.yml


delete:
  image: curlimages/curl
  script:
    - 'curl --header "Job-Token: ${CI_JOB_TOKEN}" --request DELETE "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default"'

main.tf

terraform {
  backend "http" {
  }
}

resource "random_pet" "main" {
  length = 2
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sir l33tname

Merge request reports

Loading