GitLab CI/CD variables are strings. Terraform inputs can be strings, numbers, booleans or structured values. The Python exporter gives you a first draft of a variable file, not a finished migration.

Before exporting

Use a token authorized to read variables for the intended project. The script reads it from GITLAB_API_PRIVATE_TOKEN and takes --host, --project and --output. Point it only at your trusted GitLab instance. Choose a new, private file outside your repository: the script overwrites the output path and writes values in plaintext, even if they were masked in CI.

Review the draft

  • Use the right filename. Choose project.tfvars, not project.tfvars.tf as shown upstream. Terraform treats a file ending in .tf as configuration. A file named project.tfvars is a variable file you select explicitly with -var-file.
  • Check types against your Terraform inputs. An identifier such as 00123 may need to stay a quoted string. Terraform booleans are true and false, not the True and False the script emits. Review embedded quotes and multiline values as well.
  • Check completeness and scope. The script reads one page of project variables and writes only keys and values. It doesn’t follow pagination or preserve environment scopes. Two entries with the same key can belong to different environments; keep only the one intended for this configuration.

Keep the reviewed file out of Git and CI artifacts. For the dependencies and script itself, see the exporter directory.