• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

family

Terraform GCloud VM Image Family

August 10, 2021

How to implement image family with Terraform in GCP.

Declare the machine image in terraform.tfvars.

image-family = "centos-7"

image-family = "centos-7"

Declare data type for the machine image in maint.tf.

data "google_compute_image" "my_image" {
  family  = var.image-family
  project = "your-project-id"
}

data "google_compute_image" "my_image" { family = var.image-family project = "your-project-id" }

In main.tf use “google_compute_instance” under boot disk section in main.tf.

boot_disk {
  initialize_params {
    image = data.google_compute_image.my_image.self_link
  }
}

boot_disk { initialize_params { image = data.google_compute_image.my_image.self_link } }

Filed Under: Cloud Tagged With: family, gcp, image, terraform

  • Home
  • About
  • Archives

Copyright © 2023