terraform-google-modules/terraform-google-vm

Instance Template creates pd-standard disk instead of pd-balanced

mohamedcabdiweli opened this issue · 1 comments

terraformbug2
terraformbug1

TL;DR

Despite specifying pd-balanced as the disk type in google_compute_instance_template, instances created from the template have pd-standard disks instead.

Expected behavior

When specifying pd-balanced as the disk type in the google_compute_instance_template, I expected the instances created from this template to have pd-balanced disks for both the boot disk and any additional disks, as defined in the configuration.

Observed behavior

Instead of creating instances with pd-balanced disks as specified in the google_compute_instance_template, the instances were created with pd-standard disks for both the boot disk and any additional disks. This behavior is inconsistent with the configuration provided.

Terraform Configuration

provider "google" {
  project = "my-project-id"
  region  = "us-central1"
  zone    = "us-central1-a"
}

locals {
  instances = {
    "web-test-11" = {
      "name"          = "test-1111"
      "machine_type"  = "n2d-standard-2"
      "zone"          = "us-central1-a"
      "image_project" = "windows-cloud"
      "source_image"  = "windows-server-2022-dc-v20230414"
      "disk_type"     = "pd-balanced"
      "disk_size_gb"  = 80
      "tags"          = ["egress-internet"]
      "additional_disks_web" = [
        { "type" = "pd-balanced", "size_gb" = 200, "add" = true }
      ]
    }
  }
}

resource "google_compute_instance_template" "template" {
  for_each = local.instances

  lifecycle {
    create_before_destroy = true
  }

  name_prefix  = "${each.key}-template"
  machine_type = each.value.machine_type

  disk {
    auto_delete  = true
    boot         = true
    type         = "pd-balanced"
    disk_size_gb = 80
    source_image = "projects/${each.value.image_project}/global/images/${each.value.source_image}"
  }

  dynamic "disk" {
    for_each = each.value.additional_disks_web
    content {
      auto_delete  = disk.value.add
      type         = "pd-balanced"
      disk_size_gb = disk.value.size_gb
    }
  }

  network_interface {
    network    = "default"
    subnetwork = data.google_compute_subnetwork.default.self_link
    network_ip = local.reserved_ips_web[each.key]
  }

  service_account {
    scopes = ["cloud-platform"]
  }

  tags = each.value.tags
}

data "google_compute_subnetwork" "default" {
  name   = "default"
  region = "us-central1"
}

resource "google_compute_region_instance_group_manager" "instance_group_manager" {
  name               = "managed-instance-group"
  base_instance_name = "instance"
  region             = "us-central1"
  target_size        = length(local.instances)
  dynamic "version" {
    for_each = google_compute_instance_template.template

    content {
      instance_template = version.value.self_link
    }
  }

  named_port {
    name = "https"
    port = 443
  }

  update_policy {
    type                         = "PROACTIVE"
    instance_redistribution_type = "NONE"
    minimal_action               = "RESTART"
    max_surge_fixed              = 0
    max_unavailable_fixed        = 4
    replacement_method           = "RECREATE"
  }
}

Terraform Version

Terraform v1.3.0
+ provider registry.terraform.io/hashicorp/external v2.3.1
+ provider registry.terraform.io/hashicorp/google v4.63.1
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1

Additional information

No response