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

Question: Change order of passing variables in InitAndApply #613

Open
tomarv2 opened this issue Sep 11, 2020 · 3 comments
Open

Question: Change order of passing variables in InitAndApply #613

tomarv2 opened this issue Sep 11, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@tomarv2
Copy link

tomarv2 commented Sep 11, 2020

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]
@tomarv2
Copy link
Author

tomarv2 commented Sep 11, 2020

Related to: #256

@brikis98 brikis98 added enhancement New feature or request help wanted labels Sep 13, 2020
@brikis98
Copy link
Member

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?

@yorinasub17
Copy link
Contributor

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.

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

No branches or pull requests

4 participants