» google_compute_machine_image

Represents a MachineImage resource. Machine images store all the configuration, metadata, permissions, and data from one or more disks required to create a Virtual machine (VM) instance.

To get more information about MachineImage, see:

» Example Usage - Machine Image Basic

resource "google_compute_instance" "vm" {
  provider     = google-beta
  name         = "vm"
  machine_type = "n1-standard-1"

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }

  network_interface {
    network = "default"
  }
}

resource "google_compute_machine_image" "image" {
  provider        = google-beta
  name            = "image"
  source_instance = google_compute_instance.vm.self_link
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource.

  • source_instance - (Required) The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


  • description - (Optional) A text description of the resource.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/global/machineImages/{{name}}
  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

MachineImage can be imported using any of these accepted formats:

$ terraform import google_compute_machine_image.default projects/{{project}}/global/machineImages/{{name}}
$ terraform import google_compute_machine_image.default {{project}}/{{name}}
$ terraform import google_compute_machine_image.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.