Skip to content

feat: Add stdin support for terragrunt run command#1580

Merged
james00012 merged 1 commit intomainfrom
pass-stdin
Aug 12, 2025
Merged

feat: Add stdin support for terragrunt run command#1580
james00012 merged 1 commit intomainfrom
pass-stdin

Conversation

@james00012
Copy link
Copy Markdown
Contributor

Summary

  • Added stdin support to the terragrunt stack run command, enabling execution of console-like operations that require stdin input
  • Follows the same pattern as the existing terraform console implementation

Test plan

✅ Updated test suite to include terragrunt console test with stdin
✅ Existing terragrunt tests continue to pass
✅ Example usage demonstrates how to get computed local variable values

Example usage

This PR enables users to get computed local variable values in Terratest, similar to how it's done with echo 'local.mylocal' | terragrunt run -- console:

terragruntOptions := &terragrunt.Options{
    TerragruntDir: "../examples/terragrunt-example",
    TerragruntBinary: "terragrunt",
    Stdin: strings.NewReader("local.mylocal"),
    ExtraArgs: []string{"console"},
}

// Run terragrunt stack run -- console with stdin
output, err := terragrunt.TgStackRunE(t, terragruntOptions)

// Output will contain the computed value of local.mylocal
assert.Contains(t, output, "expected_value")

This addresses the client request for using Terratest to get computed values of local variables, providing the same functionality as the CLI command echo 'local.mylocal' | terragrunt run -- console.

Copy link
Copy Markdown
Contributor

@yhakbar yhakbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not actually being added to the stack run command, right? It's just being added the the general shell package?

@james00012 james00012 changed the title feat: Add stdin support for terragrunt stack run command feat: Add stdin support for terragrunt run command Aug 12, 2025
@james00012 james00012 merged commit baa4582 into main Aug 12, 2025
2 of 3 checks passed
@james00012 james00012 deleted the pass-stdin branch August 12, 2025 23:50
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.

2 participants