idoavrah / terraform-tui

Terraform textual UI
https://pypi.org/project/tftui/
Apache License 2.0
973 stars 30 forks source link

IndexError: list index out of range #43

Closed nikola197 closed 7 months ago

nikola197 commented 7 months ago

Hello, I tried using tftui with my Terraform code that uses multiple providers and modules, but I get this error IndexError: list index out of range every time I try running it.

Providers:

terraform {
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.6"
    }
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = ">= 2.23.0"
    }
    helm = {
      source  = "hashicorp/helm"
      version = ">= 2.11.0"
    }
    kubectl = {
      source  = "gavinbunney/kubectl"
      version = ">= 1.14.0"
    }
  }
}

When I try running tftui on simple/low resources count repositories, cli works like a charm.

Here is the log I got: tftui_error_log.txt

Can you help me with the error, I will be glad to provide any additional info you may need.

Thank you!

idoavrah commented 7 months ago

Hi Nikola,

Thanks for the catch and for posting this issue :)

I was able to recreate the error in one of my GCP workloads. The root cause is using strings with dots as keys for multiple resources (in a for_each statement). This happens often in GCP when initializing Google Cloud APIs, I'm guessing you do something like this (as I do):

resource "google_project_service" "api" {
  for_each = toset([
    "apikeys.googleapis.com",
    "certificatemanager.googleapis.com",
  ])
  service = each.key
}

This approach creates resources such as this:

module.spoke.google_project_service.api["apikeys.googleapis.com"]
module.spoke.google_project_service.api["certificatemanager.googleapis.com"]

I'll try and fix the parsing error this weekend, I'll update here when it's ready.

idoavrah commented 7 months ago

@nikola197 Please test the new version, should fix the issue (v0.10.1).

It is published on Pypi; Homebrew formulae will follow shortly.

nikola197 commented 7 months ago

Hi @idoavrah Thank you for being so responsive and for a really quick fix.

Now it is working for GCP as well.

Thank you a lot and keep up with the good work!