Create an instance template for a MIG with preemptible VMs

Create an instance template which you can use to create a managed instance group (MIG) with preemptible VMs.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

resource "google_compute_instance_template" "default" {
  name         = "preemptible-template"
  machine_type = "n1-standard-1"
  disk {
    source_image = "debian-cloud/debian-11"
  }
  network_interface {
    network = "default"
  }
  scheduling {
    preemptible       = "true"
    automatic_restart = "false"
  }
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.