Skip to content

fix: support terragrunt 1.x non-interactive mode and workspace commands - #154

Open
afreidah wants to merge 1 commit into
leg100:masterfrom
afreidah:fix-terragrunt-non-interactive-flag
Open

afreidah wants to merge 1 commit into
leg100:masterfrom
afreidah:fix-terragrunt-non-interactive-flag

Conversation

@afreidah

@afreidah afreidah commented Sep 28, 2026 •

Copy link
Copy Markdown

Fixes two terragrunt 1.x incompatibilities in terragrunt mode:

  1. Non-interactive flag. Terragrunt 1.x no longer recognises --terragrunt-non-interactive and passes it through to terraform, which fails with flag provided but not defined: -terragrunt-non-interactive. Its replacement, --non-interactive, isn't recognised by older versions, so options are now set via env vars, using both the new TG_ and old TERRAGRUNT_ names so it remains backwards compatible:

    • TG_NON_INTERACTIVE / TERRAGRUNT_NON_INTERACTIVE
    • TG_TF_FORWARD_STDOUT / TERRAGRUNT_FORWARD_TF_STDOUT (1.x no longer reads the latter)
  2. Workspace commands. Terragrunt 1.x no longer forwards unknown commands to terraform, so workspace list etc. fail and pug finds no workspaces. These are now invoked as terragrunt run -- workspace ....

Env vars tested against terragrunt v0.55.0, v0.72.0 and v1.1.4; pug tested end-to-end against a terragrunt 1.1.4 project.

Split out from #145.

@afreidah

afreidah commented Sep 28, 2026 •

Copy link
Copy Markdown
Author

@leg100 @UMMAN2005 Following up on #145. This is the flag change split out and reworked, plus a fix for workspace commands:

  • Terragrunt 1.x now rejects --terragrunt-non-interactive outright, and --non-interactive breaks older versions, so this sets both via env vars (TG_* and TERRAGRUNT_*), tested on v0.55.0, v0.72.0 and v1.1.4.
  • Terragrunt 1.x no longer passes unrecognised commands through to terraform, so pug found no workspaces; workspace commands now go through terragrunt run --.

The rebuild.sh macOS change will follow separately once I've tested it on a macbook. I've dropped the .gitignore change; editor tag files belong in a global gitignore.

The same Terragrunt 1.x change still affects pug's format and taint/untaint actions, and module dependency loading (graph-dependencies) silently breaks on every reload. Would you like me to file a follow-up issue and/or PR for those?

@afreidah

Copy link
Copy Markdown
Author

also, just want to say @leg100 that I absolutely love pug, I have used it for all of my terragrunt work for years both at work and in personal projects, and I recommend it to anybody who will listen. Criminally under-appreciated and makes large terragrunt projects a joy to work with. Keep up the good work!

@afreidah
afreidah marked this pull request as draft September 28, 2026 07:47
Terragrunt 1.x no longer recognises --terragrunt-non-interactive and
passes it through to terraform, which fails with "flag provided but not
defined". Its replacement, --non-interactive, is not recognised by older
terragrunt versions. Instead set non-interactive mode, and forwarding of
terraform stdout, via environment variables, using both the TG_ names
introduced by terragrunt's CLI redesign and the older TERRAGRUNT_ names.

Terragrunt 1.x also no longer forwards unknown commands such as
"workspace" to terraform, so pug found no workspaces. Workspace commands
are now invoked as `terragrunt run -- workspace ...`.
@afreidah
afreidah force-pushed the fix-terragrunt-non-interactive-flag branch from 7c20a8d to ff90242 Compare September 28, 2026 07:51
@afreidah afreidah changed the title fix: set terragrunt options via env vars instead of flags fix: support terragrunt 1.x non-interactive mode and workspace commands Sep 28, 2026
@afreidah
afreidah marked this pull request as ready for review September 28, 2026 07:51
@afreidah

afreidah commented Sep 28, 2026 •

Copy link
Copy Markdown
Author

so, I was trying to make it backwards compatible with the ENV var approach (which is how this is handled elsewhere anyways so it is still justified) but without the run -- bit it doesn't work on any recent version of terragrunt...BUT with that it breaks some backwards compatibility. I tried to do a bit of testing to pinpoint:

| Terragrunt                        | workspace list                  | run -- workspace list                |
|-----------------------------------|---------------------------------|--------------------------------------|
| v0.55.0, v0.72.0                  | works                           | FAILS (no command named "run")       |
| v0.73.0 - v0.77.0                 | inconclusive (see note)         | FAILS (needs --experiment            |
|                                   |                                 | cli-redesign)                        |
| v0.78.0 - v0.87.0                 | works                           | works                                |
| v0.88.0 (2025-09-26) and later,   | FAILS                           | works                                |
| including v1.1.4                  |                                 |                                      |

v0.78.0 was released 2025-05-02.

Note: for v0.73.0 - v0.77.0, plain "workspace list" failed with a terraform
version-parsing error in the test environment, so that result is inconclusive.

So I guess the question of how backwards compatible you want to be needs answering otherwise some sort of version checking logic would be required to tailor functionality...doable but could be a bit sloppy. Thoughts?

@afreidah

Copy link
Copy Markdown
Author

Just checking in so I don't forget again.

@afreidah

Copy link
Copy Markdown
Author

@leg100 any thoughts on this? Just checking in again so I don't miss replies to the PR again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant