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
output-all <var_name>
gives up too easily
#193
Comments
Just to check that I'm understanding the issue:
To be honest, this seems like the correct behavior from Terragrunt, simply because that's the exact behavior from Terraform. If the output you requested is missing, exit with an error. That said, it may make sense to add a new flag, such as |
Hi Yevgeniy! Great to talk to you after reading your blog posts and stalking you in r/devops :p. Your summary is correct.
In general I agree: it doesn't make sense to I have two terraform components, I want to fetch Now I want to fetch My expectation in both cases is that I get the variable I want with a successful return code (the presence of warning text about undefined variables is somewhat confusing in this case but not a huge deal compared to exiting non-zero thereby signaling failure to the caller of terragrunt). I don't care that Does this differ from your expectation? Do you expect the two scenarios to behave differently? Because they do :) -- the former returns warnings + nonzero exit code without the requested value, the latter returns warnings + nonzero exit code with the requested value. At the very least this seems inconsistent to me. Does this better explain why I think this is a problem? Am I missing something?
For For For |
Out of curiosity, why run |
Pragmatic answer: because that's the way kitchen-terraform works. Investigating that is next on my todo list. Design answer: I like to think of the Put another way: "why run A concrete scenario: I have a script that does Is my mental model for |
This is a compelling reason, but it seems like it's equally well supported by a
I don't think that analogy works, as it's obvious why the
The fact that
No, not at all. I agree that using the Terragrunt |
I won't reply to all of your points here. I disagree with a few (which I'm happy to discuss if you're interested) but it seems we have consensus on the usefulness of I'm fine with leaving the default behavior of My next step is still to see if I can resolve this Thanks! |
Sounds great, thanks! |
After studying the kitchen-terraform code, I don't think it's feasible to fix this problem from that side. I got my hopes up after finding newcontext-oss/kitchen-terraform#113. While that PR does make the situation better, my take (as an admittedly poor Rubyist) is that the Kitchen architecture isn't going to let me look up all the Terraform output variables once and then share that info with everything that needs it. (Put another way, there's no way to prevent kitchen from needing to do Aaron's comment indicates some re-design in their upcoming 1.0.0 release so maybe the situation will be different later. In the meantime, I'm going to look at adding this flag. |
Filed #209. Using Bonus note: even though I'm a Go noob, I found it straightforward to add this feature thanks to terragrunt's sensible organization and excellent collection of tests. Good job, team! 🎉 |
Fixed with #209 |
Context
I'm trying to use Terragrunt-style modules with kitchen-terraform for testing. Since kitchen-terraform is designed for the vanilla terraform workflow (whereas I need terragrunt's
apply-all
to invoke modules together) and since kitchen-terraform doesn't provide a lot of flexibility in configuring the terraform commands it issues, I'm working on a (currently very rough) wrapper script to translate from vanilla terraform to terragrunt *-all.kitchen-terraform uses
terraform output
andterraform output <var_name>
to collect values from the provisioned system (e.g. theworker
module provides apublic_ip
variable which is used by integration tests that want to connect to the worker instance). I'm not sure why it needs two passes to do this; I'll be looking into that with thekitchen-terraform
folks next :).Demonstrating the problem
Minimal terraform code is here but it's just this:
Here's
terragrunt output-all worker_var
:(Note that terragrunt master contains a bug such that
output-all
visits its dependencies backwards. I'm using my fix from #194 to hopefully make the example easier to follow. If you are trying to reproduce the problem with master, the behavior forbase_var
andworker_var
will be reversed (or you can build terragrunt including my fix.))The good news is that the variable we asked for is in the output (
i am base_var
). The bad news is this looks and feels like a failure due to the warning message and non-zero exit code.Worse, it is now impossible to get variables from the
worker
module since it depends onbase
, which fails. Note that the expected outputi am worker_var
does not appear:Pragmatically, this is preventing me from getting
kitchen-terraform
andterragrunt
to play together. Philosophically, I think it is incorrect forterraform output-all some_variable
to exit non-zero just becausesome_variable
isn't defined in every single module, but I am still new to Terraform so please let me know if I'm missing something here.I'm also new to Go and the terragrunt code base, but my first guess about how to solve this problem would be a new flag passed among
configstack/running_module::waitForDependencies
and friends that ignores errors in dependencies. Perhaps there's a cleaner way?The text was updated successfully, but these errors were encountered: