Skip to content
delete-state.yml 1.09 KiB
Newer Older
Timo Furrer's avatar
Timo Furrer committed
spec:
  inputs:
    # Job and Stage name
    as:
      default: 'delete-state'
      description: 'Defines the name of this job.'
    stage:
      default: 'cleanup'
      description: 'Defines the stage that this job will belong to.'

    # Configuration
    state_name:
      default: default
      description: 'Remote OpenTofu state name.'
    create_delete_state_job:
      default: 'true'
      description: 'Wheather the delete-state job should be created or not.'
    rules:
      # FIXME: eventually, we'll want to define `null` as the default,
      # but this is NOT support yet, see
      # https://gitlab.com/gitlab-org/gitlab/-/issues/440468
      default: [{when: on_success}]
      type: array
      description: 'Defines the `rules` of the job.'
Timo Furrer's avatar
Timo Furrer committed

---

'$[[ inputs.as ]]':
  stage: $[[ inputs.stage ]]
  resource_group: $TF_STATE_NAME
Timo Furrer's avatar
Timo Furrer committed
  image: curlimages/curl:latest
  variables:
    TF_STATE_NAME: $[[ inputs.state_name ]]
Timo Furrer's avatar
Timo Furrer committed
  script:
    - curl --request DELETE -u "gitlab-ci-token:$CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state/$TF_STATE_NAME"
  rules: $[[ inputs.rules ]]