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:

Open in Cloud Shell

Example Usage - Image Basic

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

  raw_disk {
    source = "https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz"
  }
}
Open in Cloud Shell

Example Usage - Image Guest Os

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

  raw_disk {
    source = "https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz"
  }

  guest_os_features {
    type = "SECURE_BOOT"
  }

  guest_os_features {
    type = "MULTI_IP_SUBNET"
  }
}
Open in Cloud Shell

Example Usage - Image Basic Storage Location

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

  raw_disk {
    source = "https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz"
  }
  storage_locations = ["us-central1"]
}

Argument Reference

The following arguments are supported:


The guest_os_features block supports:

The image_encryption_key block supports:

The raw_disk block supports:

Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

Image can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Image using one of the formats above. For example:

import {
  id = "projects/{{project}}/global/images/{{name}}"
  to = google_compute_image.default
}

When using the terraform import command, Image can be imported using one of the formats above. For example:

$ 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.