Skip to content
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

Only run the command on modules that have the specified file. #2351

Closed
villers opened this issue Nov 4, 2022 · 7 comments
Closed

Only run the command on modules that have the specified file. #2351

villers opened this issue Nov 4, 2022 · 7 comments
Labels
needs design We need to flesh out the design before we can resolve the issue stale Stale

Comments

@villers
Copy link

villers commented Nov 4, 2022

This allows to manage workspaces and vars files easily

I would create --terragrunt-layer-has-file argument to filter terragrunt modules.

exemple:

TF_WORKSPACE=staging ./terragrunt run-all plan --terragrunt-layer-has-file=/vars/staging.tfvars

with the following terragrunt config:

terraform {
  extra_arguments "var_file" {
    commands = [
      "apply",
      "plan",
      "import",
    ]
    required_var_files = ["vars/${get_env("TF_WORKSPACE")}.tfvars"]
  }
}
@villers villers changed the title Only run the command on the modules that have the specified file. Only run the command on modules that have the specified file. Nov 4, 2022
@denis256
Copy link
Member

denis256 commented Feb 1, 2023

Hello,
proposed changes, in the end, look specific for one specific case - I was wondering can't be used --terragrunt-include-dir / --terragrunt-strict-include options to pass only dependencies which have required .tfvars. file?

References:

https://terragrunt.gruntwork.io/docs/reference/cli-options/#terragrunt-include-dir

https://github.com/denis256/terragrunt-tests/tree/master/include-dir-dependencies

@denis256 denis256 added the needs design We need to flesh out the design before we can resolve the issue label Feb 1, 2023
@villers
Copy link
Author

villers commented Feb 16, 2023

Hey @denis256 😄

Thanks for considering my pull request for Terragrunt. While I appreciate the team's suggestion of a pre-calculation option for the list of directories to process, I've tested it out and found that it's not very practical for everyday use.

As an alternative, I suggested a feature that only runs a command on modules with a specified file, which I think is a more practical and efficient solution for managing modules and workspaces in Terragrunt. This feature not only simplifies the process of managing modules, but also addresses a common request from the Terragrunt community for a workspace management tool. Plus, my pull request has been tested and is ready to be merged, so I believe it would be a great addition to the tool.

If you have any further questions or concerns about my proposal, feel free to let me know. Thanks for your consideration.

@dim-ops
Copy link

dim-ops commented Mar 24, 2023

Hey @denis256,

I need of this feature.

I saw a PR created by @villers, is it possible to merge it ?

@yhakbar
Copy link
Collaborator

yhakbar commented Aug 1, 2024

Hey folks,

I know this issue was left stale for a while, but I would like to get some clarity on the use of the word "layer" here. Where does that come from? Does something in the docs refer to a "layer" in this way?

@villers
Copy link
Author

villers commented Aug 9, 2024

Hey yhakbar,

I know this issue has been dormant for a while, but I’d like to get some clarity on the use of the word “layer” in this context. In this case, a “layer” typically refers to a Terragrunt folder. Each “layer” represents a separate folder in your Terragrunt setup, which usually corresponds to different environments, modules, or components.

Is there something specific in the Terraform or Terragrunt documentation that clarifies this, or are we just using “layer” as shorthand here?

Thanks in advance!

@yhakbar
Copy link
Collaborator

yhakbar commented Aug 9, 2024

Currently, we're using the terminology "module":

You can see here (under Quick Detour on "Units") that we're trying to standardize on "Unit" for the folders that have terragrunt.hcl files in them and "Stack" for folders with multiple Units (and we're proposing adding tooling to make working with Stacks better).

I think a solution that's a lot more simple in your use-case is to leverage terragrunt-include-dir, like @denis256 mentioned.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.

@github-actions github-actions bot added the stale Stale label Dec 14, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs design We need to flesh out the design before we can resolve the issue stale Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants