cool-easter-32542
04/02/2025, 12:31 PM[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