Skip to content

Gitlab Terraform integration

Use curl to get the state file

Create Gitlab token with api scope and export it:

export GITLAB_TOKEN=...

Export gitlab project ID and terraform state file URL:

export TF_ADDRESS="https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/terraform/state/default"

curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" $TF_ADDRESS

Issues

error looking up module versions: 401 Unauthorized

Put token in ~/.terraformrc like this:

credentials "gitlab.com" {
  token = "<myAPIkey>"
}

Alternatives to managing gitlab with terraform