Terratest: Change order of passing variables in InitAndApply

708 views Asked by At

Question on: https://github.com/gruntwork-io/terratest

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]

I have asked this question in terratest GitHub, want to see if anyone has faced this.

1

There are 1 answers

0
tomarv2 On

I think I found it, there is work in progress on this: https://github.com/gruntwork-io/terratest/pull/256