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

Wrap budget_name output with length check #673

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

jpedro
Copy link
Contributor

@jpedro jpedro commented Jan 5, 2022

When running terraform plan -refresh-only and var.create_budget turns from false to true (via passing a non-null budget_amount in create_budget = var.budget_amount != null this fails with the message:

│ Error: Invalid index
│
│   on .terraform/modules/project.project-factory/modules/budget/outputs.tf line 19, in output "name":
│   19:   value       = var.create_budget ? google_billing_budget.budget[0].name : ""
│     ├────────────────
│     │ google_billing_budget.budget is empty tuple
│
│ The given key does not identify an element in this collection value: the
│ collection has no elements.

Seems related to hashicorp/terraform#23222

Run on: Terraform v1.0.11 on darwin_amd64

When running `terraform plan -refresh-only` and `var.create_budget` turns from `false` to `true` (via passing a non-null `budget_amount` in [`create_budget = var.budget_amount != null`](https://github.com/terraform-google-modules/terraform-google-project-factory/blob/master/main.tf#L90) this fails with the message:

```
│ Error: Invalid index
│
│   on .terraform/modules/project.project-factory/modules/budget/outputs.tf line 19, in output "name":
│   19:   value       = var.create_budget ? google_billing_budget.budget[0].name : ""
│     ├────────────────
│     │ google_billing_budget.budget is empty tuple
│
│ The given key does not identify an element in this collection value: the
│ collection has no elements.
```

Seems related to hashicorp/terraform#23222

Run on: Terraform v1.0.11 on darwin_amd64
@jpedro jpedro requested a review from a team as a code owner January 5, 2022 15:50
@jpedro jpedro changed the title Wrap budget_name output with length check Wrap budget_name output with length check Jan 5, 2022
@comment-bot-dev
Copy link

Thanks for the PR! 🚀
✅ Lint checks have passed.

@jpedro
Copy link
Contributor Author

jpedro commented Jan 5, 2022

I signed the CLA. So please run a re-scan.

Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

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

This feels like an upstream issue, but happy to add this workaround.

@morgante morgante merged commit 21871b2 into terraform-google-modules:master Jan 5, 2022
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.

3 participants