google_compute_image

Creates a bootable VM image resource for Google Compute Engine from an existing tarball. For more information see the official documentation and API.

Example Usage

resource "google_compute_image" "bootable-image" {
  name = "my-custom-image"

  raw_disk {
    source = "https://storage.googleapis.com/my-bucket/my-disk-image-tarball.tar.gz"
  }
}

resource "google_compute_instance" "vm" {
  name         = "vm-from-custom-image"
  machine_type = "n1-standard-1"
  zone         = "us-east1-c"

  boot_disk {
    initialize_params {
      image = "${google_compute_image.bootable-image.self_link}"
    }
  }

  network_interface {
    network = "default"
  }
}

Argument Reference

The following arguments are supported: (Note that one of either source_disk or raw_disk is required)

  • name - (Required) A unique name for the resource, required by GCE. Changing this forces a new resource to be created.
  • description - (Optional) The description of the image to be created

  • family - (Optional) The name of the image family to which this image belongs.

  • labels - (Optional) A set of key/value label pairs to assign to the image.

  • source_disk - (Optional) The URL of a disk that will be used as the source of the image. Changing this forces a new resource to be created.

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

  • raw_disk - (Optional) The raw disk that will be used as the source of the image. Changing this forces a new resource to be created. Structure is documented below.

  • create_timeout - (Deprecated) Configurable timeout in minutes for creating images. Default is 4 minutes.

The raw_disk block supports:

  • source - (Required) The full Google Cloud Storage URL where the disk image is stored.

  • sha1 - (Optional) SHA1 checksum of the source tarball that will be used to verify the source before creating the image.

  • container_type - (Optional) The format used to encode and transmit the block device. TAR is the only supported type and is the default.

Attributes Reference

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

Timeouts

google_compute_image provides the following Timeouts configuration options:

Import

VM image can be imported using the name, e.g.

$ terraform import google_compute_image.web-image my-custom-image

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/google/r/compute_image.html