Open lubo-p opened 4 years ago
Hi @lubo-p,
Always loading the terraform.tfvars
and *.auto.tfvars
files is the intended behavior reflected in the documentation. -var
and -var-file
arguments are interpreted as overrides for those automatic files, if present.
There is not currently any way to tell Terraform via the command line not to process the automatic variables. The only way to stop them being processed is to rename them to not be recognized as automatically-included.
It seems this issue is implying a feature request for some way to tell Terraform to not automatically load these files, so I'm going to label it with that in mind. Please let me know if that wasn't what you intended.
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
When running terraform plan or apply and providing custom value of -var-file and -state, the expectation is that only these specified files will be loaded.
Actual Behavior
According to my experiment if terraform.tfvars exists in the same directory and some value is missing in "custom" provided tfvar files, it will gets loaded from terrafrom.tfvars when such file should be not read at all.
Steps to Reproduce
$ terraform init $ terraform plan -var-file=./custom.tfvars -state=./custom.tfstate Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
null_resource.test_resource will be created
Plan: 1 to add, 0 to change, 0 to destroy.
Now if I delete the terraform.tfvars I get the expected behavior - asking for missing value: $ rm terraform.tfvars $ terraform plan -var-file=./custom.tfvars -state=./custom.tfstate var.test_val Enter a value:
Additional Context
References