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
Enable to use of terragrunt instead of terraform #224
Comments
If you want an example of what my IAC looks like with terragrunt - based on terragrunt recommended structure: https://github.com/ctrlaltdev/ctrlalt.dev/tree/main/infra Under modules, you will find the TF modules, and under config, you will find the terragrunt settings to use those modules. |
The following is copied from https://gitlab.com/infracost/infracost-gitlab-ci/-/issues/1#note_448546649 as it's also a recent and relevant request:
|
So maybe mimick terragrunt *-all command behavior In terragrunt, you can either go in a module and run a command like Maybe infracost could have a similar way of running for terragrunt, that will look recursively in the children folders for terragrunt modules and run against them? |
With terragrunt you have an option of a pre & post hook, maybe that's an option for infracost to run at either one of those points? https://terragrunt.gruntwork.io/docs/features/before-and-after-hooks/ |
@robh007 Hmmm, before apply seems a good one. And it could run for each directory, but probably the output will be messed up. Will try that just for seeing how things will break. |
Yea @ayr-ton I've had a little play with some code today.
So the above works but as you say the output is generated per directory, the output is to stdout & doesn't look any different. You could also perhaps output to a json file then use the hcl functions to merge the JSON files together. The main issue I see is that the TF source is nested within a random directory structure. What you can also do with terragrunt is use a parameter |
@robh007 Yeah, the output is uncomprehensive. :-( |
@ctrlaltdev and @ayr-ton, just FYI that @robh007, @aliscott, myself and another user were online on Discord#terragrunt so we had a spontaneous call to discuss the options. @aliscott is digging into this and we'll post updates here. Feel free to jump into #terragrunt if you prefer to have longer discussions there. |
We've added an So at the moment for our own infrastructure I can get a table of all the costs by running a script like this: This is now released in v0.7.4. Please try this out and let us know if it can help with your use cases. |
Given that we now have https://www.infracost.io/docs/#terragrunt-users, should we close this issue? People can still leave feedback here or open another ticket |
@alikhajeh1 I liked it a lot. :-) |
I always use terragrunt as a wrapper around terraform because I reuse terraform modules between environments or accounts - and it also allows me to dynamically configure the tf backend and provider I use.
So technically, I don't have a tfdir to provide infracost, as terragrunt only 'compiles' it when I run it.
The good news is most of the terraform commands works with terragrunt (
terragrunt show
for instance)So I think something like
--use-tg
that would substitute terraform with terragrunt would be great!The text was updated successfully, but these errors were encountered: