terraform-google-modules/terraform-google-vm

Error specifying source_image or source_image_family

fabmaiad opened this issue · 0 comments

TL;DR

When I specify source_image or source_image_family it seems to concatenate the two values, so I get errors in terraform apply.

Expected behavior

Create a template instance of a specific OS Family that I configure

Observed behavior

This is a part of an output from running "terraform plan". Note that the value of source_image is concatenated with the default value centos-cloud.

 + disk {
          + auto_delete  = true
          + boot         = true
          + device_name  = (known after apply)
          + disk_size_gb = 100
          + disk_type    = "pd-standard"
          + interface    = (known after apply)
          + mode         = (known after apply)
          + source_image = "centos-cloud/ubuntu-1804-lts"
          + type         = "PERSISTENT"
        }

I checked in the module, it seems to concatenate the default value of source_image with the value of source_image_family, see;

source_image = var.source_image != "" ? format("${local.source_image_project}/${local.source_image}") : format("${local.source_image_project}/${local.source_image_family}")

Terraform Configuration

locals {
      jenkins-vm-hostname  = "jenkins-vm"
      num_instances        = "1"
      machine_type         = "e2-small"
      source_image_family  = "ubuntu-1804-lts"
  }

  module "jenkins-vm-template" {
      source      = "terraform-google-modules/vm/google//modules/instance_template"
      version     = "8.0.0"
      name_prefix = format("%s%s", local.jenkins-vm-hostname, "template")

      region              = var.default_region
      project_id          = module.cicd-project.project_id
      network             = module.cicd-vpc.network_name
      subnetwork          = module.cicd-vpc.subnets_names[0]
      machine_type        = local.machine_type
      source_image_family = local.source_image_family

    tags                = ["jenkins-vm"]

    service_account = {
      email = google_service_account.sa["sa-jenkins-vm"].email
      scopes = ["storage-rw", "logging-write", "monitoring-write", "cloud-platform"]
  }
  startup_script  = ""
  }


### Terraform Version

```sh
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/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/time v0.9.1

Additional information

No response