Comments (13)
Ah, perhaps then modifying find_in_parent_folder() to find the matching filename instead of .terragrunt?
Yea, this would make sense. The API would be simple too: find_in_parent_folder(filename)
. If you don't specify a filename
, the default is .terragrunt
.
from terragrunt.
@evanstachowiak If you have different files, I guess you would still like to point to them case by case.
wouldn't https://github.com/gruntwork-io/terragrunt#cli-options
--terragrunt-config: A custom path to the .terragrunt file. May also be specified via the TERRAGRUNT_CONFIG environment variable. The default path is .terragrunt in the current directory.
solve your case?
from terragrunt.
@josesa, unfortunately not. That switch sets the config only for the current working directory. When looking for the parent config, terragrunt still uses the default filename of .terragrunt and this doesn't seem to be modifiable. This is problematic because the top-level config file contains the region, bucket name, etc whereas each .terragrunt-custom-name file only contain an include.
from terragrunt.
Could you provide a bit more info so we can understand the use case? What does your folder structure look like? Why does a root .terragrunt
file not work for it? What solution are you proposing? Thanks!
from terragrunt.
hey @brikis98, sorry for the delay, I've been on vacation.
I have a similar structure to what you outlined in your blogpost: https://blog.gruntwork.io/how-to-create-reusable-infrastructure-with-terraform-modules-25526d65f73d#.tgyv0iyus
However, I don't have a separate folder for each environment, I just have a top-level services directory and then handle the configuration based on the environment.
The issue specifically is: I'm using a different bucket per account & region to store the terraform state. In this case, sharing a top-level .terragrunt file does not work for me.
My proposed solution: Respect the --terragrunt-config flag for the parent .terragrunt as well. Then it can support different s3 buckets using includes.
from terragrunt.
Would using environment variables work for you? That is, instead of setting the include
path to a hard-coded value or find_in_parent_folder()
, you set it to an environment variable Terragrunt can look up. You could then set that variable accordingly to whatever value you need.
If so, then once #77 is merged, you should be good to go.
from terragrunt.
Yes, this could work but it still seems inconsistent to specify a terrgrunt_config file but this is only for the current directory and for some reason the parent config ignores this flag. Maybe this is just me.
Another drawback of using get_env is that there is no way to check this into source control. Using this I will have to somehow coordinate the env variables across developer machines.
from terragrunt.
Yes, this could work but it still seems inconsistent to specify a terrgrunt_config file but this is only for the current directory and for some reason the parent config ignores this flag.
The --terragrunt-config
flag tells Terragrunt where to find your .terragrunt
file. The command-line flags have no relation to what that .terragrunt
file may choose to do. For example, if that file happens to use the include
keyword, it's up to the file, and not the command-line flags, to figure out the right way to specify the path to the included file. You can do that by hard-coding it, by having it found automatically using find_in_parent_folder()
, or, hopefully soon, via env vars.
Another drawback of using get_env is that there is no way to check this into source control. Using this I will have to somehow coordinate the env variables across developer machines.
If your developers had to pass in a special --terragrunt-config
flag anyway, then isn't that something you'd have to do across all developer machines too? I guess you could create a wrapper script to do that automatically, but then a wrapper script could just as easily set an env var.
from terragrunt.
Ah, perhaps then modifying find_in_parent_folder() to find the matching filename instead of .terragrunt? Otherwise, you are correct I can just hardcode the value, that's a good idea.
As for the --terragrunt-config, yes, there is some knowledge needed there but then the appropriate .terragrunt* files will already be checked into source control, so it is self-documented in a way.
Thanks for all the feedback!
from terragrunt.
@evanstachowiak I was just trolling through open issues and came across this. I'm wondering how you might have changed your workflow/directory structure now that Terragrunt has deprecated support for the .terragrunt
configuration file and instead expects configuration to be in the terraform.tfvars
file? See here for details.
Would you still lobby for updating the find_in_parent_folder()
function to find_in_parent_folder_(filename)
?
from terragrunt.
@conorgil now that terraform has native remote locking support I've just migrated away from terragrunt. I already had a wrapper script to handle multiple environments and profiles so now I don't need terragrunt for the locking.
from terragrunt.
@evanstachowiak Thanks for the response and glad you found a workflow that works for you. Do you think this issue can be closed?
from terragrunt.
Seems like this issue is no longer relevant/needed. Closing.
from terragrunt.
Related Issues (20)
- Severe Performance Issues: O(n^2) Redundancy in Terragrunt Locals and Root Includes HOT 13
- TERRAGRUNT_DOWNLOAD setting is ignored for any dependent modules HOT 1
- Failed to detect a version allowing to call tofu HOT 3
- Error - Download Latest Terragrunt version: 'v0.58.10' HOT 6
- Terragrunt Provider Cache with multiple platforms HOT 6
- Terragrunt provider caching does not appear to be creating symlinks, resulting in multiple copies of providers HOT 1
- Inadvertent switch to OpenTofu when terraform has been the default binary to look for HOT 3
- Terraform >= 1.6.0 endpoints.s3 problem
- Add Extra Debug Logging to Help When Users Use `sops_decrypt_file` HOT 2
- Wrong default tool when both Terraform and OpenTofu are installed? HOT 8
- `get_parent_terragrunt_dir()` function behavior does not match documentation
- goroutine fatal error: concurrent map writes
- Clarify when we issue major vs. minor vs. patch releases HOT 1
- Authentication signature from unknown issue when installing registry.opentofu.org/datadog/datadog v3.39.0 HOT 9
- Unable to apply multiple modules at once. HOT 2
- There is no variable named "dependency" - terragrunt 0.58.14 (again, 3rd time) HOT 3
- (Re)run `terragrunt run-all destroy` even if some resources tore down successfully while others failed HOT 4
- [Feature Request] terragrunt hclfmt path to format (supporting wildcard or regex)
- Issue with find_in_parent_folders function HOT 5
- run-all cycle error on config folder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terragrunt.