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

Helper function to load tfvars into environment variables #27

Open
raymondbutcher opened this issue Jul 5, 2019 · 0 comments
Open

Helper function to load tfvars into environment variables #27

raymondbutcher opened this issue Jul 5, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@raymondbutcher
Copy link
Owner

In the workspace example it mirrors (symlinks) a tfvars file into the current directory so it will get loaded automatically (and the other files in the params dir won't get loaded).

created = workflow.mirror_files(
"../stack.tf.py", f"../../params/{stack}.{workspace}.auto.tfvars"
)

This symlink could be avoided by parsing the file and exporting TF_VAR_* environment variables for each value found in the file.

This would be a work around for Terraform not being able to load tfvars per workspace and perhaps other use cases I haven't thought of. Maybe people just prefer their params to be sitting together in a separate directory, I don't know.

Usage might be like this:

workflow.export_variables_from_file(f"{terraform.workspace}.workspace.tfvars")
@raymondbutcher raymondbutcher added the enhancement New feature or request label Feb 27, 2020
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

1 participant