I wanted to set up Terraform "http" backend (https://developer.hashicorp.com/terraform/language/settings/backends/http) and one of the options (which is recommended) is to use environment variables as shown below:
I have set up those environment variables on my local machine (using export
command) to point to my GitLab repository state storage and in the terraform{}
block I leave the backend "http" {}
block empty as shown:
But once I run the command terraform init
, it still asks me to enter the data manually even though I have environment variables set up:
Why is that so ? Has anyone encountered similar situation and has an answer why do my environment variables are not working ? Maybe there is an additional step I need to make ?
Turns out the problem was related to environment variables. I was only setting env variables for the shell process that I had open and then I opened another shell the variables were not there anymore.
I added the variables to the .bashrc
file so every time a new shell is launched it automatically adds the environment variables also.