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

Panic in terraform-provider-google_v4.44.0_x5 plugin #13097

Closed
aebrahim opened this issue Nov 21, 2022 · 3 comments · Fixed by GoogleCloudPlatform/magic-modules#6860, #13108 or GoogleCloudPlatform/terraform-validator#1146
Assignees

Comments

@aebrahim
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

1.3.2

Affected Resource(s)

Unknown

Terraform Configuration Files

variable "project_id" {
  type    = string
  default = "my-project-id"
}

variable "region" {
  type        = string
  description = "Main location for resources"
  default     = "us-central1"
}

variable "container" {
  type        = string
  description = "Full path of Docker container to deploy"
}

resource "google_compute_network" "vpc" {
  provider                = google-beta
  project                 = var.project_id
  routing_mode            = "GLOBAL"
  auto_create_subnetworks = true
  name                    = "vpc"
}

resource "google_compute_global_address" "private_ip_block" {
  name          = "private-ip-block"
  purpose       = "VPC_PEERING"
  address_type  = "INTERNAL"
  ip_version    = "IPV4"
  prefix_length = 20
  network       = google_compute_network.vpc.self_link
}

resource "google_service_networking_connection" "private_vpc_connection" {
  network                 = google_compute_network.vpc.self_link
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.private_ip_block.name]
}

resource "google_vpc_access_connector" "connector" {
  name          = "vpcconn"
  project       = var.project_id
  provider      = google-beta
  region        = var.region
  ip_cidr_range = "10.8.0.0/28"
  network       = google_compute_network.vpc.name
}

resource "google_compute_subnetwork" "bastion_subnet" {
  project                  = var.project_id
  name                     = "bastion-subnet"
  region                   = var.region
  ip_cidr_range            = "10.127.0.0/20"
  network                  = google_compute_network.vpc.self_link
  private_ip_google_access = true
}

module "gce-container" {
  source  = "terraform-google-modules/container-vm/google"
  version = ">=3.0.0, <4.0"

  container = {
    image = var.container
    tty   = true

    env = [
      {
        name  = "DEBUG"
        value = (local.debug) ? "true" : "false"
      }
    ]

    command = ["sleep", "infinity"]
  }

  restart_policy = "Always"
}


module "iap_bastion" {
  source       = "terraform-google-modules/bastion-host/google"
  version      = ">=5.0.0, <6.0"
  project      = var.project_id
  network      = google_compute_network.vpc.self_link
  subnet       = google_compute_subnetwork.bastion_subnet.self_link
  host_project = var.project_id

  image_project = "cos-cloud"
  image_family  = "cos-97-lts"
  preemptible   = false
  metadata = {
    gce-container-declaration = module.gce-container.metadata_value
  }
  labels = {
    container-vm = module.gce-container.vm_container_label
  }
  members = [
    local.debug ? "domain:example.com" : "group:[email protected]",
  ]
  startup_script = <<-EOT
  docker image prune -af
  EOT
}

resource "google_project_iam_member" "bastion_permissions_sql_connect" {
  project = var.project_id
  member  = "serviceAccount:${module.iap_bastion.service_account}"
  role    = "roles/cloudsql.client"
}

resource "google_project_iam_member" "bastion_permissions_sql_login" {
  project = var.project_id
  member  = "serviceAccount:${module.iap_bastion.service_account}"
  role    = "roles/cloudsql.instanceUser"
}

Panic Output

module.iap_bastion.module.instance_template.google_compute_instance_template.tpl: Creating...
╷
│ Error: Request cancelled
│ 
│   with module.iap_bastion.module.instance_template.google_compute_instance_template.tpl,
│   on .terraform/modules/iap_bastion.instance_template/modules/instance_template/main.tf line 62, in resource "google_compute_instance_template" "tpl":
│   62: resource "google_compute_instance_template" "tpl" {
│ 
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

Stack trace from the terraform-provider-google_v4.44.0_x5 plugin:

panic: interface conversion: interface {} is nil, not int

goroutine 823 [running]:
github.com/hashicorp/terraform-provider-google/google.expandAdvancedMachineFeatures({0x32a1a98, 0xc000b07e00})
	github.com/hashicorp/terraform-provider-google/google/compute_instance_helpers.go:399 +0x171
github.com/hashicorp/terraform-provider-google/google.resourceComputeInstanceTemplateCreate(0x0?, {0x2d22880?, 0xc000d56000})
	github.com/hashicorp/terraform-provider-google/google/resource_compute_instance_template.go:1022 +0x3a5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x329c660?, {0x329c660?, 0xc000b40e40?}, 0xd?, {0x2d22880?, 0xc000d56000?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00023a620, {0x329c660, 0xc000b40e40}, 0xc0007e4680, 0xc000b07b00, {0x2d22880, 0xc000d56000})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa7a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0008ab5c0, {0x329c660?, 0xc000b40d80?}, 0xc000c5d630)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0000b2140, {0x329c660?, 0xc000b40570?}, 0xc0009d37a0)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:813 +0x4fc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x2cb4f00?, 0xc0000b2140}, {0x329c660, 0xc000b40570}, 0xc0009d3730, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000001e0, {0x32a1af8, 0xc000658b60}, 0xc000a73e60, 0xc00066f950, 0x[440](https://github.com/DelfinaCare/gaia/actions/runs/3518071851/jobs/5898106596#step:8:441)ef40, 0x0)
	google.golang.org/[email protected]/server.go:1340 +0xd13
google.golang.org/grpc.(*Server).handleStream(0xc0000001e0, {0x32a1af8, 0xc000658b60}, 0xc000a73e60, 0x0)
	google.golang.org/[email protected]/server.go:1713 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-google_v4.44.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
@slevenick
Copy link
Collaborator

Can you reproduce this without a module? I'd like to test this out and see how we missed this bug in the test/release process.

@slevenick
Copy link
Collaborator

I'll be releasing 4.44.1 today if everything goes according to plan to fix this issue

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.