terragrunt: Output is written twice and incorrectly to StdErr

Terragrunt output is being rendered twice, once normally and then to StdErr

Example:

terragrunt version v0.45.10
############################################################
RUNNING 'terragrunt run-all plan --terragrunt-non-interactive'
############################################################
**time=2023-05-10T11:17:37Z level=info msg=The stack at /azp/_work/1/s/infrastructure/Azure/terraform/environments/QA/mono will be processed in the following order for command** plan:
Group 1
- Module /azp/_work/1/s/infrastructure/Azure/terraform/environments/QA/mono



Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing modules...

[REMOVED]

Initializing provider plugins...
- Finding hashicorp/azuread versions matching "~> 2.36.0"...
- Finding hashicorp/random versions matching "~> 3.1"...
- Finding latest version of hashicorp/time...
- Finding latest version of hashicorp/helm...
- Finding latest version of hashicorp/kubernetes...
- Finding hashicorp/azurerm versions matching "~> 3.48.0"...
- Installing hashicorp/time v0.9.1...
- Installed hashicorp/time v0.9.1 (signed by HashiCorp)
- Installing hashicorp/helm v2.9.0...
- Installed hashicorp/helm v2.9.0 (signed by HashiCorp)
- Installing hashicorp/kubernetes v2.20.0...
- Installed hashicorp/kubernetes v2.20.0 (signed by HashiCorp)
- Installing hashicorp/azurerm v3.48.0...
- Installed hashicorp/azurerm v3.48.0 (signed by HashiCorp)
- Installing hashicorp/azuread v2.36.0...
- Installed hashicorp/azuread v2.36.0 (signed by HashiCorp)
- Installing hashicorp/random v3.5.1...
- Installed hashicorp/random v3.5.1 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

[REMOVED]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
##[error]time=2023-05-10T11:17:37Z level=info msg=The stack at /azp/_work/1/s/infrastructure/Azure/terraform/environments/QA/mono will be processed in the following order for command plan:
Group 1
- Module /azp/_work/1/s/infrastructure/Azure/terraform/environments/QA/mono


##[error]Script has output to stderr. Failing as failOnStdErr is set to true.

running

terragrunt run-all plan

should reproduce the issue. It appears to be linked to run-all However, this will also result in incorrect output written to StdErr

terragrunt plan --terragrunt-log-level debug

Expected behavior This should not write to StdErr when there are no errors. Running in Azure DevOps results in the build failing.

Versions

  • Terragrunt version: v0.45.10
  • Terraform version: 1.4.6
  • Environment details Ubuntu 20.04 (agent), Windows 11

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Hi @levkohimins , thanks for your reply! I had known that solution before, but it unfortunately reduces the amount of information that is output from terragrunt, which we rely during our CI/CD processes.

In the meantime, the solution I have presented has been working fine, so I believe it is a more comprehensive solution for our use case

You can check the return code on the terragrunt command.

Using run-all isn’t ideal as you’ll get a mass of output that’s hard to distinguish. You could create a template pipeline and loop over your individual components.