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

[Feature request] extra args injection to terraform command #27

Closed
kertzi opened this issue Jun 8, 2021 · 3 comments
Closed

[Feature request] extra args injection to terraform command #27

kertzi opened this issue Jun 8, 2021 · 3 comments

Comments

@kertzi
Copy link

kertzi commented Jun 8, 2021

Hello,
Your tool looks promising but to make it even more flexible I would like to suggest following new feature:

Is it possible to add configuration which allows flags to be passed to terraform plan/apply command.

Use case:
We use .tfvars files which holds values for each environment so when terraform plan or terraform apply
is executed it will need -var-file parameter which have environment specific values.
For example final apply command looks like:

terraform plan -var-file=devel.tfvars

Is it possible to add configuration parameter to .tfmigrate.hcl or directly tfmigrate command which enables these
extra parameters injected to terraform plan/apply calls?

Suggestion:

tfmigrate {
  migration_dir = "./migrations"
  plan_extra_args = "-var-file=somevars.tfvars"
  apply_extra_args="-var-file=somevars.tfvars"
}
@minamijoyo
Copy link
Owner

@kertzi Thank you for sharing your use-case!

I think it's better to add a new attribute in a migration file rather than tfmigrate's configuration file because a var file is typically related to its workspace.

For a workaround, you can pass any CLI flags to the terraform command via environment variables named TF_CLI_ARGS_<name>. For example TF_CLI_ARGS_plan="-var-file=somevars.tfvars"
https://www.terraform.io/docs/cli/config/environment-variables.html#tf_cli_args-and-tf_cli_args_name

You can also change environment variables per directory with direnv. For how to integrate them with tfmigrate, see my comment here: #3 (comment)

@kertzi
Copy link
Author

kertzi commented Jun 10, 2021

@kertzi Thank you for sharing your use-case!

I think it's better to add a new attribute in a migration file rather than tfmigrate's configuration file because a var file is typically related to its workspace.

For a workaround, you can pass any CLI flags to the terraform command via environment variables named TF_CLI_ARGS_<name>. For example TF_CLI_ARGS_plan="-var-file=somevars.tfvars"
https://www.terraform.io/docs/cli/config/environment-variables.html#tf_cli_args-and-tf_cli_args_name

You can also change environment variables per directory with direnv. For how to integrate them with tfmigrate, see my comment here: #3 (comment)

Thanks for reply, I will check that!

@minamijoyo
Copy link
Owner

I'm going to close this because there has been no activity on this recently. Please feel free to reopen this if you have any questions or suggestions. Thanks!

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

No branches or pull requests

2 participants