Skip to content

googleComputeImage

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

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.computeImage.ComputeImage(this, "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",
    },
  ],
});

Example Usage - Image Guest Os

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.computeImage.ComputeImage(this, "example", {
  guest_os_features: [
    {
      type: "SECURE_BOOT",
    },
    {
      type: "MULTI_IP_SUBNET",
    },
  ],
  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",
    },
  ],
});

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 [aZ]([AZ09]*[aZ09])? 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.

  • diskSizeGb - (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.

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

  • imageEncryptionKey - (Optional) Encrypts the image using a customer-supplied encryption key. After you encrypt an image with a customer-supplied key, you must provide the same key if you use the image later (e.g. to create a disk from the image) Structure is documented below.

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

  • licenses - (Optional) Any applicable license URI.

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

  • sourceDisk - (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.

  • sourceImage - (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
  • sourceSnapshot - (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 guestOsFeatures 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 multiIpSubnet, secureBoot, sevCapable, uefiCompatible, virtioScsiMultiqueue, windows, and gvnic.

The imageEncryptionKey block supports:

  • kmsKeySelfLink - (Optional) The self link of the encryption key that is stored in Google Cloud KMS.

  • kmsKeyServiceAccount - (Optional) The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used.

The rawDisk block supports:

  • containerType - (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}}

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

  • creationTimestamp - Creation timestamp in RFC3339 text format.

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

  • selfLink - The URI of the created resource.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 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.