Missing backend address when using gitlab backed for terraform

I am trying to use gitlab as terraform as backend and to use gitlab ci as described in the docs.

I am able to use gitlab backend for terraform when I use “terraform init” as described here and I am able to reuse the state in other places (using infrastructure → terraform and selecting “copy terraform init command”)

The CI part doesn’t work as described in the docs. I get an error saying

...
$ gitlab-terraform plan
Initializing the backend...
╷
│ Error: "address": required field is not set
...

from build (#2486373730) · Jobs · Moozer / terraform-gitlab-test · GitLab

I have made a very minimal project that follows the guide, and doesn’t work.

As I read the docs, it should Just Work.

How do you do it?
Do you add TF_ADDRESS and the other environment vars to you ci pipeline?

1 Like

@moozer you need to set the variable TF_STATE_NAME else gitlab will not be able to generate TF_ADDRESS required for the http backend