Skip to content

Fix TerragruntArgs and TerraformArgs being ignored#1617

Merged
james00012 merged 2 commits intomainfrom
fix-terragrunt-args-1609-2
Nov 18, 2025
Merged

Fix TerragruntArgs and TerraformArgs being ignored#1617
james00012 merged 2 commits intomainfrom
fix-terragrunt-args-1609-2

Conversation

@james00012
Copy link
Copy Markdown
Contributor

@james00012 james00012 commented Nov 16, 2025

Fixes #1609

Problem

TerragruntArgs and TerraformArgs were being ignored when running terragrunt commands, affecting all terragrunt module functions.

Solution

Core Fix:

  • Implement buildTerragruntArgs() with proper argument ordering: TerragruntArgs → --non-interactive → command → TerraformArgs
  • Replace GetCommonOptions() and GetArgsForCommand() which weren't including user-provided args
  • Update to modern terragrunt syntax: <cmd> --all instead of deprecated run-all <cmd>

New in this PR:

  • Comprehensive test coverage (38 tests including unit, integration, and E2E tests)
  • Module README with examples, key concepts, and unsupported features list

Breaking Changes

Removed internal functions (low impact - use public APIs instead):

  • GetCommonOptions(), GetArgsForCommand(), ArgSeparator constant

Behavior change: TerragruntArgs/TerraformArgs now work correctly (previously ignored)

Testing

All tests pass with terragrunt v0.80.4 and v0.93.5.

…ompatibility

This PR fixes the terragrunt module to properly handle TerragruntArgs and
TerraformArgs, and updates compatibility for Terragrunt v0.93.5+.

**Argument Handling:**
- Implement proper argument ordering: TerragruntArgs → --non-interactive → command → TerraformArgs
- Replace GetCommonOptions/GetArgsForCommand with buildTerragruntArgs() for consistent argument construction
- Remove deprecated -- separator approach that no longer works in newer Terragrunt versions

**v0.93.5 Compatibility:**
- Update command syntax from deprecated `run-all <cmd>` to new `<cmd> --all` format:
  - ApplyAll: `apply --all`
  - DestroyAll: `destroy --all`
  - PlanAllExitCode: `plan --all`

**Stack Commands:**
- Fix flag placement in stack output (-json flag now appears after command, not in TerragruntArgs)
- Fix --no-color flag format for proper parsing
- Add TerraformArgs support to stack commands

**Terragrunt Command Updates:**
- Add --non-interactive flag automatically for all Terragrunt commands (v0.93.5+)
- Remove terraform-specific flags (-input=false, -auto-approve) from TgApplyAllE and TgDestroyAllE
  that are not supported by Terragrunt run-all commands

**ValidateInputsE Function:**
- Update from deprecated `validate-inputs` to new `hcl validate --inputs` command (Terragrunt v0.88.1+)
- Update TestExtraArgsHelp to handle new command format in help output

- Update Terragrunt version from v0.80.4 to v0.93.5 in CircleCI config

Fixes #1609
@james00012 james00012 changed the title Fix terragrunt module for TerragruntArgs/TerraformArgs and v0.93.5+ compatibility Fix TerragruntArgs and TerraformArgs being ignored Nov 16, 2025
Add comprehensive test coverage and documentation to complement the
TerragruntArgs/TerraformArgs fix.

**Test Enhancements:**
- Add unit tests for core cmd.go functions:
  - TestValidateOptions - validates option validation logic
  - TestBuildTerragruntArgs - table-driven tests for arg construction
  - TestPrepareOptions - tests default value setting
  - TestEnvVarsPropagation - verifies env vars are passed through

- Add E2E workflow tests in terragrunt_e2e_test.go:
  - TestTerragruntEndToEndIntegration - full Plan→Apply→Plan→Destroy workflow
  - TestStackEndToEndIntegration - stack Init→Generate→Run→Clean workflow

**Documentation:**
- Add README.md for terragrunt module with:
  - Requirements (Terragrunt + Terraform/OpenTofu)
  - How to specify terraform vs opentofu binary
  - Key concepts (Options, TerragruntArgs vs TerraformArgs)
  - Function reference (Stack vs Non-Stack)
  - Practical examples
  - List of unsupported terragrunt features
  - Compatibility notes

Test Coverage: All 38 tests pass, including new unit tests and E2E tests
@james00012 james00012 merged commit 2f049a3 into main Nov 18, 2025
2 of 3 checks passed
@james00012 james00012 deleted the fix-terragrunt-args-1609-2 branch November 18, 2025 00:31
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.

Options "TerragruntArgs" are ignored

2 participants