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

-out not working when redirecting terragrunt STDERR #3708

Open
1 task
Erbrowl opened this issue Dec 24, 2024 · 3 comments
Open
1 task

-out not working when redirecting terragrunt STDERR #3708

Erbrowl opened this issue Dec 24, 2024 · 3 comments
Assignees
Labels
awaiting response Waiting for a response or more data from issue reporter bug Something isn't working

Comments

@Erbrowl
Copy link

Erbrowl commented Dec 24, 2024

Describe the bug

When redirecting STDERR, -out CLI option doesn't generate and output file with plan info.

Steps To Reproduce

# Creates plan.tfplan with plan info
terragrunt plan -out=plan.tfplan

# Doesn't create plan.tfplan, still redirects STDERR to errors.txt
terragrunt plan -out=plan.tfplan 2> errors.txt

Expected behavior

Creation of -out specified output plan file and redirection of STDERR to file working at the same time.

Nice to haves

  • Terminal output :
Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"

Versions

  • Terragrunt version: 0.71.1
  • OpenTofu/Terraform version: 1.10.3
  • Environment details: Debian docker container & WSL distro

Additional context

Same with or without --terragrunt-forward-tf-stdout flag

@Erbrowl Erbrowl added the bug Something isn't working label Dec 24, 2024
@wakeful
Copy link
Contributor

wakeful commented Dec 24, 2024

can you try this? should work in v0.71.0+

@Erbrowl
Copy link
Author

Erbrowl commented Dec 24, 2024

can you try this? should work in v0.71.0+

The redirection works properly, with and without --terragrunt-forward-tf-stdout flag.

The issue is more about the -out= not generating an output file in this specific case.

@yhakbar yhakbar self-assigned this Jan 10, 2025
@yhakbar
Copy link
Collaborator

yhakbar commented Jan 10, 2025

I tried to reproduce locally without success, @Erbrowl .

Do you mind sharing a fixture that can reproduce the issue you're experiencing?

$ terragrunt --version
terragrunt version v0.71.5
$ fd -tf -x bash -c 'echo "# {}" && cat {} && echo'
# ./mise.toml
[tools]
terragrunt = "0.71.5"

# ./main.tf
resource "null_resource" "empty" {
  triggers = {
    always_run = timestamp()
  }

  provisioner "local-exec" {
    command = "echo 'Hello, World!'"
  }
}

# ./terragrunt.hcl
$ terragrunt plan -out plan.tfplan 2> errors.txt
10:56:01.548 STDOUT tofu: OpenTofu used the selected providers to generate the following execution
10:56:01.548 STDOUT tofu: plan. Resource actions are indicated with the following symbols:
10:56:01.548 STDOUT tofu:   + create
10:56:01.548 STDOUT tofu: OpenTofu will perform the following actions:
10:56:01.548 STDOUT tofu:   # null_resource.empty will be created
10:56:01.548 STDOUT tofu:   + resource "null_resource" "empty" {
10:56:01.548 STDOUT tofu:       + id       = (known after apply)
10:56:01.548 STDOUT tofu:       + triggers = {
10:56:01.548 STDOUT tofu:           + "always_run" = (known after apply)
10:56:01.548 STDOUT tofu:         }
10:56:01.548 STDOUT tofu:     }
10:56:01.548 STDOUT tofu: Plan: 1 to add, 0 to change, 0 to destroy.
10:56:01.548 STDOUT tofu:
10:56:01.548 STDOUT tofu: ─────────────────────────────────────────────────────────────────────────────
10:56:01.548 STDOUT tofu: Saved the plan to: plan.tfplan
10:56:01.548 STDOUT tofu: To perform exactly these actions, run the following command to apply:
10:56:01.548 STDOUT tofu:     tofu apply "plan.tfplan"
$ eza -la plan.tfplan
.rw-r--r--@ 2.0k yousif 10 Jan 10:56 plan.tfplan

$ eza -la errors.txt
.rw-r--r--@ 2.4k yousif 10 Jan 10:56 errors.txt
$ terragrunt show plan.tfplan
10:56:25.433 STDOUT tofu: OpenTofu used the selected providers to generate the following execution
10:56:25.433 STDOUT tofu: plan. Resource actions are indicated with the following symbols:
10:56:25.433 STDOUT tofu:   + create
10:56:25.433 STDOUT tofu: OpenTofu will perform the following actions:
10:56:25.433 STDOUT tofu:   # null_resource.empty will be created
10:56:25.433 STDOUT tofu:   + resource "null_resource" "empty" {
10:56:25.433 STDOUT tofu:       + id       = (known after apply)
10:56:25.433 STDOUT tofu:       + triggers = {
10:56:25.433 STDOUT tofu:           + "always_run" = (known after apply)
10:56:25.433 STDOUT tofu:         }
10:56:25.433 STDOUT tofu:     }
10:56:25.433 STDOUT tofu: Plan: 1 to add, 0 to change, 0 to destroy.
10:56:25.433 STDOUT tofu:

@yhakbar yhakbar added the awaiting response Waiting for a response or more data from issue reporter label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Waiting for a response or more data from issue reporter bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants