In c3w2a1 - Assignment 1 of week 2. [Data Storage and Queries Course] - How does Terraform gets the Variable values.
I do not see it getting passed using tfcars file or not using command line when terraform plan or apply.
List of Varaibales :
project
region
vpc_id
private_subnet_a_id
db_sg_id
source_host
source_port
(… more are there)
Hello @joyan
It is nice that you are paying attention to these details
These terraform variables are read from the OS environment variables and are defined in the setup_jupyter_env.sh file. When you run source scripts/setup_jupyter_env.sh in the command line, these variables are initiated. The following is part of the setup_jupyter_env.sh file.
Thank you Amir. This step creates a bashrc file with export commands. At time of SSH initialization, bashrc executes are create environment variables like TF_VAR_project. How does terraform knows that it need to look at environment variables starting with “TF_VAR” and look for remaining part of the environment variable name to get terraform variable? Is this a by -default - configuration of Terraform execution?
Hello again @joyan
Yes, this is a by default configuration of Terraform. For further information, you can take a look at this part of the Terraform documentation.