terraform-google-modules / terraform-google-kubernetes-engine

Configures opinionated GKE clusters
https://registry.terraform.io/modules/terraform-google-modules/kubernetes-engine/google
Apache License 2.0
1.14k stars 1.17k forks source link

Error: Invalid address to set #1544

Closed joby-kurian closed 1 year ago

joby-kurian commented 1 year ago

TL;DR

I am using GKE and ASM module for my development since august 2022. I was able to deploy GKE and ASM using below repo "terraform-google-modules/kubernetes-engine/google//modules/asm" and version = "20.0.0". But today I am getting one strange error, even without any change from my end. I tried with old branch which run successfully, also giving this error.

Error: Invalid address to set: []string{"addons_config", "0", "config_connector_config"} │ │ with module.asm.module.asm.data.google_container_cluster.asm, │ on .terraform/modules/asm.asm/modules/asm/main.tf line 28, in data "google_container_cluster" "asm": │ 28: data "google_container_cluster" "asm" {

Expected behavior

The code should run without any error.

Observed behavior

But it's throwing "Error: Invalid address to set".

Error: Invalid address to set: []string{"addons_config", "0", "config_connector_config"} │ │ with module.asm.module.asm.data.google_container_cluster.asm, │ on .terraform/modules/asm.asm/modules/asm/main.tf line 28, in data "google_container_cluster" "asm": │ 28: data "google_container_cluster" "asm" {

Terraform Configuration

module "asm" {
  source  = "terraform-google-modules/kubernetes-engine/google//modules/asm"
  version = "20.0.0"

  project_id                = var.project_id
  cluster_name              = var.cluster_name
  cluster_location          = var.cluster_location
  enable_cni                = true
  enable_fleet_registration = true
  enable_mesh_feature       = true
  enable_vpc_sc             = true
  fleet_id                  = var.fleet_name
}

Terraform Version

Terraform v1.3.3

google = {
      source  = "hashicorp/google"
      version = ">= 4.20.0"
    }
    vault = {
      source  = "hashicorp/vault"
      version = "2.23.0"
    }

Additional information

Since last week I was able to run the code without any issues, not sure what happened now.

remisauvat commented 1 year ago

I just faced the same error with the gke module. I think it's a new option available in the google provider in 4.49.0 https://github.com/hashicorp/terraform-provider-google/pull/13380

Terraform configuration

module "gke" {                                                                    
  source                     = "terraform-google-modules/kubernetes-engine/google"
  version                    = "~> 24.1"                                          

Terraform version

Terraform v1.3.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v4.49.0
+ provider registry.terraform.io/hashicorp/google-beta v4.49.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.17.0
+ provider registry.terraform.io/hashicorp/random v3.4.3

Workaround

I had to downgrade the google provider to 4.48.0

terraform {                       
  required_providers {            
    google = {                    
      source  = "hashicorp/google"
      version = "~>4.48.0"        
    }                             
joby-kurian commented 1 year ago

As you suggested, it is working after google provider downgrade. Thank you so much for the update.

bmistrapau commented 1 year ago

Hello,

We are facing the same bug described above, when using google provider v4.50.0 and gke terraform module v23.1.0 :

Error: Invalid address to set: []string{"addons_config", "0", "config_connector_config"}

  with module.oro-gke-private-cluster01.module.acm[0].module.registration.data.google_container_cluster.primary,
  on .terraform/modules/oro-gke-private-cluster01.acm.registration/modules/local/terraform-google-modules/kubernetes-engine/google/v23.1.0/modules/fleet-membership/main.tf line 23, in data "google_container_cluster" "primary":
  23: data "google_container_cluster" "primary" {

Error: Invalid address to set: []string{"addons_config", "0", "config_connector_config"}

  with module.oro-gke-private-cluster01.module.asm[0].data.google_container_cluster.asm,
  on .terraform/modules/oro-gke-private-cluster01.asm/modules/local/terraform-google-modules/kubernetes-engine/google/v23.1.0/modules/asm/main.tf line 28, in data "google_container_cluster" "asm":
  28: data "google_container_cluster" "asm" {

The terraform code referenced is:

# Retrieve GKE cluster info
data "google_container_cluster" "primary" {
  name     = var.cluster_name
  location = var.location
  project  = var.project_id
}

and

data "google_container_cluster" "asm" {
  project  = var.project_id
  name     = var.cluster_name
  location = var.cluster_location

  depends_on = [var.module_depends_on]
}

Thank you, Bogdan

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days