» google_compute_image

Represents an Image resource.

Google Compute Engine uses operating system images to create the root persistent disks for your instances. You specify an image when you create an instance. Images contain a boot loader, an operating system, and a root file system. Linux operating system images are also capable of running containers on Compute Engine.

Images can be either public or custom.

Public images are provided and maintained by Google, open-source communities, and third-party vendors. By default, all projects have access to these images and can use them to create instances. Custom images are available only to your project. You can create a custom image from root persistent disks and other images. Then, use the custom image to create an instance.

To get more information about Image, see:

» Example Usage - Image Basic

resource "google_compute_image" "example" {
  name = "example-image"

  raw_disk {
    source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"

» Example Usage - Image Guest Os

resource "google_compute_image" "example" {
  name = "example-image"

  raw_disk {
    source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"

  guest_os_features {
    type = "SECURE_BOOT"

  guest_os_features {
    type = "MULTI_IP_SUBNET"

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

  • description - (Optional) An optional description of this resource. Provide this property when you create the resource.

  • disk_size_gb - (Optional) Size of the image when restored onto a persistent disk (in GB).

  • family - (Optional) The name of the image family to which this image belongs. You can create disks by specifying an image family instead of a specific image name. The image family always returns its latest image that is not deprecated. The name of the image family must comply with RFC1035.

  • guest_os_features - (Optional) A list of features to enable on the guest operating system. Applicable only for bootable images. Structure is documented below.

  • labels - (Optional) Labels to apply to this Image.

  • licenses - (Optional) Any applicable license URI.

  • raw_disk - (Optional) The parameters of the raw disk image. Structure is documented below.

  • source_disk - (Optional) The source disk to create this image based on. You must provide either this property or the rawDisk.source property but not both to create an image.

  • source_image - (Optional) URL of the source image used to create this image. In order to create an image, you must provide the full or partial URL of one of the following: The selfLink URL This property The rawDisk.source URL The sourceDisk URL

  • source_snapshot - (Optional) URL of the source snapshot used to create this image. In order to create an image, you must provide the full or partial URL of one of the following: The selfLink URL This property The sourceImage URL The rawDisk.source URL The sourceDisk URL

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

The guest_os_features block supports:

  • type - (Required) The type of supported feature. Read Enabling guest operating system features to see a list of available options. Possible values are MULTI_IP_SUBNET, SECURE_BOOT, SEV_CAPABLE, UEFI_COMPATIBLE, VIRTIO_SCSI_MULTIQUEUE, and WINDOWS.

The raw_disk block supports:

  • container_type - (Optional) The format used to encode and transmit the block device, which should be TAR. This is just a container and transmission format and not a runtime format. Provided by the client when the disk image is created. Default value is TAR. Possible values are TAR.

  • sha1 - (Optional) An optional SHA1 checksum of the disk image before unpackaging. This is provided by the client when the disk image is created.

  • source - (Required) The full Google Cloud Storage URL where disk storage is stored You must provide either this property or the sourceDisk property but not both.

» 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/images/{{name}}

  • archive_size_bytes - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes).

  • creation_timestamp - Creation timestamp in RFC3339 text format.

  • label_fingerprint - The fingerprint used for optimistic locking of this resource. Used internally during updates.

  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

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

» Import

Image can be imported using any of these accepted formats:

$ terraform import google_compute_image.default projects/{{project}}/global/images/{{name}}
$ terraform import google_compute_image.default {{project}}/{{name}}
$ terraform import google_compute_image.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.