Coder Social home page Coder Social logo

Comments (13)

brikis98 avatar brikis98 commented on August 26, 2024 1

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.

josesa avatar josesa commented on August 26, 2024

@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.

evanstachowiak avatar evanstachowiak commented on August 26, 2024

@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.

brikis98 avatar brikis98 commented on August 26, 2024

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.

evanstachowiak avatar evanstachowiak commented on August 26, 2024

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.

brikis98 avatar brikis98 commented on August 26, 2024

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.

evanstachowiak avatar evanstachowiak commented on August 26, 2024

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.

brikis98 avatar brikis98 commented on August 26, 2024

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.

evanstachowiak avatar evanstachowiak commented on August 26, 2024

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.

conorgil avatar conorgil commented on August 26, 2024

@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.

evanstachowiak avatar evanstachowiak commented on August 26, 2024

@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.

conorgil avatar conorgil commented on August 26, 2024

@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.

brikis98 avatar brikis98 commented on August 26, 2024

Seems like this issue is no longer relevant/needed. Closing.

from terragrunt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.