google_compute_instance_from_template

Manages a VM instance resource within GCE. For more information see the official documentation and API.

This resource is specifically to create a compute instance from a given source_instance_template. To create an instance without a template, use the google_compute_instance resource.

Example Usage

resource "google_compute_instance_template" "tpl" {
  name         = "template"
  machine_type = "e2-medium"

  disk {
    source_image = "debian-cloud/debian-11"
    auto_delete  = true
    disk_size_gb = 100
    boot         = true
  }

  network_interface {
    network = "default"
  }

  metadata = {
    foo = "bar"
  }

  can_ip_forward = true
}

resource "google_compute_instance_from_template" "tpl" {
  name = "instance-from-template"
  zone = "us-central1-a"

  source_instance_template = google_compute_instance_template.tpl.self_link_unique

  // Override fields from instance template
  can_ip_forward = false
  labels = {
    my_key = "my_value"
  }
}

Argument Reference

The following arguments are supported:


In addition to these, all arguments from google_compute_instance are supported as a way to override the properties in the template. All exported attributes from google_compute_instance are likewise exported here.

To support removal of Optional/Computed fields in Terraform 0.12 the following fields are marked Attributes as Blocks:

Attributes Reference

All exported attributes from google_compute_instance are exported here. See https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#attributes-reference for details.

Import

This resource does not support import.

Timeouts

This resource provides the following Timeouts configuration options: configuration options: