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

tg_command Fails to Recognize Multi-Level Folder Paths with Wildcards #80

Open
guicrocetti opened this issue Nov 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@guicrocetti
Copy link

*Describe the Bug
The tg_command function does not interpret multi-level folder paths with wildcards correctly. For example, running the following command in the terminal works as expected:

terragrunt run-all plan --terragrunt-working-dir my-folder/*/*-test

In this case, terragrunt successfully plans all content within folders ending in "-test".

However, attempting to run the same command with tg_command results in an error indicating the folder path cannot be found:

tg_command: 'run-all plan --terragrunt-working-dir ${{ vars.PROJECT_ID }}/*/*-${{ env.git_environment }}'

Error received:

ERROR  lstat my-folder/*/*-test: no such file or directory

Interestingly, removing the wildcard syntax resolves the issue, as shown below:

tg_command: 'run-all plan --terragrunt-working-dir ${{ vars.PROJECT_ID }}/folder-name/folder-prefix-${{ env.git_environment }}'

This simplified version also works without error:

tg_command: 'run-all plan --terragrunt-working-dir ${{ vars.PROJECT_ID }}'

However, using a partial wildcard pattern like the example below still triggers a "folder not found" error:

tg_command: 'run-all plan --terragrunt-working-dir ${{ vars.PROJECT_ID }}/folder-name/*-${{ env.git_environment }}'

Suggestion:
The issue might stem from tg_command interpreting * as a literal folder name, rather than as a wildcard.

Expected Behavior
The tg_command should recognize and correctly handle folder paths with multi-level wildcard patterns, similar to the behavior of the terragrunt command in the terminal.

Terragrunt Action Version: V2
Environment Details:

  • tg_version: "0.67.16"
  • tf_version: "1.9.7"
@guicrocetti guicrocetti added the bug Something isn't working label Nov 6, 2024
@yhakbar
Copy link

yhakbar commented Dec 20, 2024

Hey @guicrocetti ,

The difference between the two is what your shell is doing, not what Terragrunt is doing.

When you run this:

terragrunt run-all plan --terragrunt-working-dir my-folder/*/*-test

It's not actually Terragrunt that's evaluating those wildcards, it's your shell. You can probably see the same error if you do this:

terragrunt run-all plan --terragrunt-working-dir 'my-folder/*/*-test'

Some (basically all, I think) shells expand globs when they are used like that.

The terragrunt-working-dir CLI command is not meant to be used with multiple directories, so I don't think we're interested in adding logic to handle this on the go side if a user explicitly passes in a * string.

Why not use terragrunt-include-dir with terragrunt-strict-include instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants