Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terratest forces the precedence of var-file values over -vars in the apply cmd #1160

Open
HadwaAbdelhalem opened this issue Jul 19, 2022 · 1 comment · May be fixed by #1190
Open

Terratest forces the precedence of var-file values over -vars in the apply cmd #1160

HadwaAbdelhalem opened this issue Jul 19, 2022 · 1 comment · May be fixed by #1190
Labels
enhancement New feature or request

Comments

@HadwaAbdelhalem
Copy link
Contributor

HadwaAbdelhalem commented Jul 19, 2022

Terraform allows user to pass -var-file to set a collection of variables while also pass -var to set/overwrite some of the values on the fly.

In Terraform, Precedence of those variables is set based on the order of the cmd arguments as they were provided.. more details here

Current Terratest implementation forces the order of the options when building the cmd to always pass -var before -var-file, which ensures values inside -var-file to have higher precedence.

if includeVars {
terraformArgs = append(terraformArgs, FormatTerraformVarsAsArgs(options.Vars)...)
terraformArgs = append(terraformArgs, FormatTerraformArgs("-var-file", options.VarFiles)...)
}

This could make things harder when testing or deploying multiple environments/instances where common configurations are grouped in one var-file and the test/deploy only needs to override one or two values to address a certain case.

@denis256 denis256 added the enhancement New feature or request label Oct 3, 2022
Darych pushed a commit to Darych/terratest that referenced this issue Oct 14, 2022
@Darych Darych linked a pull request Oct 14, 2022 that will close this issue
4 tasks
@dannyger97
Copy link

Any update on this? Running into this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants