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

Import cluster/nodepools fails after #247 #294

Closed
AkhilGNair opened this issue Oct 23, 2019 · 4 comments
Closed

Import cluster/nodepools fails after #247 #294

AkhilGNair opened this issue Oct 23, 2019 · 4 comments
Assignees
Labels
bug Something isn't working triaged Scoped and ready for work

Comments

@AkhilGNair
Copy link

AkhilGNair commented Oct 23, 2019

After the change made in #247 for region to become optional, import now fails on regional clusters.

terraform import -config=/some/backend module.gke.google_container_node_pool.pools[0] path/to/pool
module.gke.google_container_node_pool.pools[0]: Importing from ID "path/to/pool"...
module.gke.google_container_node_pool.pools[0]: Import prepared!
  Prepared google_container_node_pool for import
module.gke.google_container_node_pool.pools[0]: Refreshing state... [id=path/to/pool]

Error: Invalid index

  on .terraform/modules/gke/modules/beta-private-cluster/main.tf line 37, in locals:
  37:   region   = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
    |----------------
    | var.zones is empty list of string

The given key does not identify an element in this collection value.

In the resource definition, region is being passed in as below

module "gke" {
  ...
  source = "git@github.com:terraform-google-modules/terraform-google-kubernetes-engine.git//modules/beta-private-cluster?ref=master"
  ...
  region = var.region
  ...
}

@paulpalamarchuk FYI :)

@morgante morgante added bug Something isn't working triaged Scoped and ready for work labels Oct 24, 2019
@julianvmodesto
Copy link
Contributor

Even when providing zones, this issue persists.

Seems like this may be the upstream issue:
hashicorp/terraform#22721 (comment)

Dev25 added a commit to Dev25/terraform-google-kubernetes-engine that referenced this issue Nov 4, 2019
@omazin omazin self-assigned this Dec 9, 2019
@omazin
Copy link
Contributor

omazin commented Dec 9, 2019

Hi @AkhilGNair, can you try overriding the region variable as follows:

  • import -var 'region=us-east-2' ...
  • create a terraform.tfvars or *.auto.tfvars with the following contents region = "us-east-2" and run your import command
  • create a file named region.tfvars with the same contents and run import -var-file="region.tfvars" ...

If in all cases it still fails then it's indeed a terraform's bug.

omazin added a commit to omazin/terraform-google-kubernetes-engine that referenced this issue Dec 9, 2019
…ules#294, but the real issue's with terraform not able to override a default value when importing resources is there..
@omazin
Copy link
Contributor

omazin commented Dec 9, 2019

Was able to reproduce the error using the simple_regional_private example. The error log's below:

module.gke.google_container_cluster.primary: Importing from ID "flask-app-254610/europe-west3/simple-regional-private-clustertest123"...
module.gke.google_container_cluster.primary: Import prepared!
  Prepared google_container_cluster for import
module.gke.google_container_cluster.primary: Refreshing state... [id=simple-regional-private-clustertest123]

Error: Invalid index

  on ../../modules/private-cluster/main.tf line 37, in locals:
  37:   region   = var.region == null ? join("-", slice(split("-", var.zones[0]), 0, 2)) : var.region
    |----------------
    | var.zones is empty list of string

The given key does not identify an element in this collection value.

Created the workaround #376, but the real issue's with terraform not able to override a default value when importing resources is still there. We need them to fix the issue hashicorp/terraform#22721

@morgante
Copy link
Contributor

#376 should have fixed this.

CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this issue Jul 15, 2024
…ules#294, but the real issue's with terraform not able to override a default value when importing resources is there..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Scoped and ready for work
Projects
None yet
Development

No branches or pull requests

5 participants