terratest
terratest copied to clipboard
Question: Change order of passing variables in InitAndApply
This call:
terraform.InitAndApply(t, terraformOptions)
parses vars
and var-file
and does apply, I want to see if there is a way to change the order, I want -var-file
to go first and -var
to go after, as far as I know, the last one overrides the previous value.
The reason: there can be common variables in the file and a user would want to override them as needed in tests.
Current order:
terraform [apply -input=false -auto-approve -var prjid=demo-ecs-E9p9SV -var teamid=test -var-file xyz.tfvars -lock=false]
Expected order:
terraform [apply -input=false -auto-approve -var-file xyz.tfvars -var prjid=demo-ecs-E9p9SV -var teamid=test -lock=false]
Related to: https://github.com/gruntwork-io/terratest/pull/256
Hm, I don't think simply swapping the order is the right answer, as I'm sure there are users who prefer the current order too. So is there a way to allow users to specify the order?
I suspect that if one is sensitive to the order of how the varfile and vars are passed in, it makes more sense to manually construct the list of args using an ExtraArgs
type option variable. It does add redundancy to the API, but I think is more robust to the use cases where the exact order of args matters.