You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Terraform and Ansible together, I tend to have to define more vars as env vars than I'd like (TF_VAR*). To make values easily available to both of these programs, I default to using env vars usually. Since I have to manage that in a shell script I tend to manage more vars as env vars than I would want to.
I would prefer to define as many vars in HCL or Ansible yaml as possible (including Ansible crypt encrypted vars), but if defined in HCL these values aren't readily available to ansible shell scripts in Terraform local shell provisioners.
It would be a fantastic workflow improvement if we could flag Terraform vars to be exported into shells, and made available via the standard $TF_VAR_* prefix. This would allow the majority of variables I use to be removed out of bash and defined in HCL or (yaml possibly?)
Attempted Solutions
Define all vars as env vars.
Proposal
Provide a flag when defining a var or local that it will be exported as an env var.
References
The text was updated successfully, but these errors were encountered:
With remote-exec and other similar provisioners, I'd suggest writing a file to the machine containing your variables that you can use in whatever way is appropriate to the OS you are provisioning.
I'd also like to draw attention to the provisioners documentation where we have some suggestions for alternatives to using provisioners. We consider provisioners a "last resort" and find that there are usually (but not always!) better alternatives.
Current Terraform Version
Use-cases
When using Terraform and Ansible together, I tend to have to define more vars as env vars than I'd like (TF_VAR*). To make values easily available to both of these programs, I default to using env vars usually. Since I have to manage that in a shell script I tend to manage more vars as env vars than I would want to.
I would prefer to define as many vars in HCL or Ansible yaml as possible (including Ansible crypt encrypted vars), but if defined in HCL these values aren't readily available to ansible shell scripts in Terraform local shell provisioners.
It would be a fantastic workflow improvement if we could flag Terraform vars to be exported into shells, and made available via the standard $TF_VAR_* prefix. This would allow the majority of variables I use to be removed out of bash and defined in HCL or (yaml possibly?)
Attempted Solutions
Define all vars as env vars.
Proposal
Provide a flag when defining a var or local that it will be exported as an env var.
References
The text was updated successfully, but these errors were encountered: