Help for the VSCode editor.
-
How can we use environment variables to pass input variables in terraform scripts?
Terraform looks for exported environment variables with names beginning
TF_VAR_
TF_VAR_<variable_name>
-
Which method has the highest priority in Variable Definition Precedence?
Refer to the documentation
Command line flags
-var
or-var-file
-
Which one of the following commands is a valid way to make use of a custom variable file with the terraform apply command?
By convention, variables files have the extension
.tfvars
or.tfvars.json
terraform apply -var-file variables.tfvars
-
Information only
-
What will happen if we run terraform plan command right now?
terraform plan
Inspect the output.
-
Information only
-
Declare the variable called filename with type string in the file variables.tf.
Don't have to specify a default value.-
Add file
variables.tf
-
Insert variable definition
Reveal
variable "filename" { type = string }
-
-
If we run terraform apply with a -var command line flag as shown below, which value would be considered by terraform?
Don't run this now:
terraform apply -var filename=/root/tennis.txt
We are explicitly setting the value of the input variable created in Q7 to
/root/tennis.txt
-
Information only