<Comment on #21567 Parameters with `terraform_back...
# github-notifications
c
Comment on #21567 Parameters with `terraform_backend` target Discussion answered by lilatomic TLDR: Technically possible but not ideal. It would be pretty easy for us to add an extra option for args to pass to the backend. Does it make sense to pass those per-deployment instead of globally? I don't think parametrising within the tfbackend file is possible in Terraform. There's an open issue about that. Do let me know if I'm wrong, though. If it does work, the option
[download-terraform].extra_env_vars
will allow you to pass (or pass through from your current env, or template with Pant's interpolation) envvars in the runs of the Terraform processes. The recommendation there, which doesn't currently work with Pants, is to use
-backend-config
with key-value pairs. Passing that through Pants doesn't work, as
[download-terraform].args
is passed to
apply
, where it doesn't work. Terraform has the functionality to pass arguments to just one
terraform
subcommand with
TF_CLI_ARGS_name
. This sortof works, but passing
-backend-config=my.tfbackend
(which Pants does automatically) overrides the ones from the envvar. If you don't have Pants pass a value for the tfbackend, you can push all your settings into this envvar and it works, but it's definitely not ideal. You'd then have Pants do the interpolation in the config file [download-terraform] extra_env_vars=[ "TF_CLI_ARGS_init=-backend-config=path=/%(buildroot)s/b.tfstate", ] pantsbuild/pants