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

duplicate error log output #3470

Closed
grimm26 opened this issue Oct 11, 2024 · 1 comment
Closed

duplicate error log output #3470

grimm26 opened this issue Oct 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@grimm26
Copy link
Contributor

grimm26 commented Oct 11, 2024

Describe the bug

When there is a terraform error, the output is shown multiple times.

Steps To Reproduce

# something simple that will generate an error
locals {
  foo = ["bar"]
}

output "foo" {
  value = local.foo[2]
}

terragrunt plan that (with a bare minimum terragrunt.hcl in place).

Expected behavior

show error once.

example(s)

❯ command terragrunt version
Terraform v1.9.5
on linux_amd64
❯ command terragrunt -version
terragrunt version v0.68.1
❯ command terragrunt plan
Initializing the backend...
Initializing provider plugins...

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.
╷
│ Error: Invalid index
│ 
│   on main.tf line 6, in output "foo":
│    6:   value = local.foo[2]
│     ├────────────────
│     │ local.foo is tuple with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵
15:33:48.309 ERROR  terraform invocation failed in .
15:33:48.309 ERROR  error occurred:

* Failed to execute "terraform plan" in .
  ╷
  │ Error: Invalid index
  │ 
  │   on main.tf line 6, in output "foo":
  │    6:   value = local.foo[2]
  │     ├────────────────
  │     │ local.foo is tuple with 1 element
  │ 
  │ The given key does not identify an element in this collection value.
  ╵
  
  exit status 1
❯ env | grep TERRAGRUNT
TERRAGRUNT_TFPATH=terraform
TERRAGRUNT_FORWARD_TF_STDOUT=1
TERRAGRUNT_DISABLE_COMMAND_VALIDATION=1
❯ unset TERRAGRUNT_FORWARD_TF_STDOUT
❯ command terragrunt plan
15:37:42.191 STDOUT terraform: Initializing the backend...
15:37:42.191 STDOUT terraform: Initializing provider plugins...
15:37:42.191 STDOUT terraform: Terraform has been successfully initialized!
15:37:42.191 STDOUT terraform: 
15:37:42.191 STDOUT terraform: You may now begin working with Terraform. Try running "terraform plan" to see
15:37:42.191 STDOUT terraform: any changes that are required for your infrastructure. All Terraform commands
15:37:42.191 STDOUT terraform: should now work.
15:37:42.191 STDOUT terraform: If you ever set or change modules or backend configuration for Terraform,
15:37:42.191 STDOUT terraform: rerun this command to reinitialize your working directory. If you forget, other
15:37:42.191 STDOUT terraform: commands will detect it and remind you to do so if necessary.
15:37:42.236 STDERR terraform: ╷
15:37:42.236 STDERR terraform: │ Error: Invalid index
15:37:42.236 STDERR terraform: │ 
15:37:42.236 STDERR terraform: │   on main.tf line 6, in output "foo":
15:37:42.236 STDERR terraform: │    6:   value = local.foo[2]
15:37:42.236 STDERR terraform: │     ├────────────────
15:37:42.236 STDERR terraform: │     │ local.foo is tuple with 1 element
15:37:42.236 STDERR terraform: │ 
15:37:42.236 STDERR terraform: │ The given key does not identify an element in this collection value.
15:37:42.236 STDERR terraform: ╵
15:37:42.240 ERROR  terraform invocation failed in .
15:37:42.240 ERROR  error occurred:

* Failed to execute "terraform plan" in .
  ╷
  │ Error: Invalid index
  │ 
  │   on main.tf line 6, in output "foo":
  │    6:   value = local.foo[2]
  │     ├────────────────
  │     │ local.foo is tuple with 1 element
  │ 
  │ The given key does not identify an element in this collection value.
  ╵
  
  exit status 1

Versions

  • Terragrunt version: 0.68.1
  • OpenTofu/Terraform version: 1.9.5
  • Environment details (Ubuntu 20.04, Windows 10, etc.): ubuntu noble
@grimm26 grimm26 added the bug Something isn't working label Oct 11, 2024
@yhakbar
Copy link
Collaborator

yhakbar commented Oct 15, 2024

This is expected behavior. The idea here is that regardless of the number of errors that are encountered during a run-all, you will not have to search through a potentially long error log to uncover the root cause of your Terragrunt run. In the future, Terragrunt will also do more to suggest fixes based on what it detects as the underlying error in the stderr from OpenTofu/Terraform, if there's a trivial fix to recommend.

If you would like a feature to opt-out of this functionality via a flag like --terragrunt-no-error-summary or something, please feel free to document that request in a new issue.

The name I'm suggesting here is derived from the rules found under "Technical Details" --> "Document Design Philosophy" here: #3445. If you have any more feedback there as well, I'd greatly appreciate it, given your great feedback on making Terragrunt usage a great experience.

@yhakbar yhakbar closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants