You need to sign in or sign up before continuing.
Initialise GitLab-backed remote Terraform state for local Terraform or OpenTofu CLIs
Problem to solve
There is a repeating sequence of manual steps, which one needs to follow to activate a remote Terraform state for local Terraform or OpenTofu CLIs:
- Go to the Terraform state page and copy the provided command.
- Replace the GITLAB_ACCESS_TOKEN with your PAT and maybe set a TF_STATE_NAME
- (Optional) Replace
terraform
withtofu
.
The last step should be recommended, since GitLab is moving towards that direction. gitlab#524144
Proposal
The glab
CLI eventually already owns its own valid token, which it could lend to Terraform when initialised through it.
It could also help with selecting a desired state name.
Yet especially being able to choose to favour OpenTofu for this flow removes possible barriers in environments that were not yet locked into the Terraform ecosystem.
Further details
Everything is already there, we just need to collect it.