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
Using vars from tfvars in locals #1621
Comments
|
Why do you use |
It doesn't work: I have already mentioned that I tried to use locals. But it doesn't work too. If you know how to get it working please give the example. |
|
You are mixing Terraform and Terragrunt locals. |
I think we can't understand each other :) |
|
Wow... Now I got it. And I don't know how to accomplish it without creating subfolders "us-east-1" and "us-east-1". Interesting question! |
If you mean creating subfolders in tf module it kills all flexibility of the cool tool terragrunt :( |
|
My guess is that you want to control this using CLI args, and unfortunately, Terragrunt doesn't read the var files that are passed in so it isn't possible doing it using tfvars in the manner you specified. However, there is an alternative that depends on environment variables that can get close to what you want. First, convert your terraform tfvars files to use json format. This is necessary so terragrunt can read them in. Then, consider the following Now you should more or less get what you want if you do: |
Thanks for the reply! |
|
You need to use |
|
I'm with @malcolm061990 on this one - I want to be able to dynamically create infrastructure (in my case on Azure) by simply passing in a new tfvar file. I.e. env1.tfvar, env2.tfvar. It seems odd that a tool designed to keep terraform DRY is unable to parse a tfvar file in its own config. Is this something that would be a welcome addition? |
|
PR to add a helper function to parse and expose tfvars file is certainly welcome! |
What are the next actions? |
If you are up for implementing a PR, you can go ahead and fork + try to implement this. Otherwise, we will have to wait to see if someone from the community wants to tackle this. Unfortunately, this isn't really a need for us internally at Gruntwork, so it's a bit low on our priority list of terragrunt improvements we would take on internally - community PR is the best way this gets implemented. |
|
Hey I am looking to pick up this up but I saw the Wondering if this is still a valid issue ? |
|
@kartikay101 this is still an issue and a PR is welcome! We recently removed all the |
|
Hey been a little busy with things here, finally got some time to look into this. Thinking about adding something like Looking into the parsing bit, is there already something in place ? I was looking to find/use something created by terraform which they might be using. |
|
Hey, sorry to ask, is read_tfvars still possible ? or is there a similar / an available alternative created meanwhile? Without this feature, we have to duplicate our vars in a tfvar and in a yaml file. |
|
Hi! Is there anyone who is working on this issue? |
|
Included in release https://github.com/gruntwork-io/terragrunt/releases/tag/v0.52.5 |
* feat: add read_tfvars_file function - closes gruntwork-io#1621 * feat: add docs * chore: add more tests * chore: fixes according to feedback
Hi. I am using v0.28.18 terragrunt.
I want to apply tf module in two different AWS regions. And I want to keep state for each region in different s3 keys like:
terragrunt-test/terraform-us-east-1.tfstate
terragrunt-test/terraform-us-east-2.tfstate
The only way I thought I could do that was using locals. My configurations:
I run:
If I hardcode aws_region in locals to us-east-1:
and run apply the correct file will be generated:
Question:
how can I use the variable from tfvars to generate provider configuration without using any environment vars?
Terraform's locals can work with vars (https://learn.hashicorp.com/tutorials/terraform/locals#use-locals-to-name-resources). So... Please, help.
The text was updated successfully, but these errors were encountered: