» google_compute_reservation

Represents a reservation resource. A reservation ensures that capacity is held in a specific zone even if the reserved VMs are not running.

Reservations apply only to Compute Engine, Cloud Dataproc, and Google Kubernetes Engine VM usage.Reservations do not apply to f1-micro or g1-small machine types, preemptible VMs, sole tenant nodes, or other services not listed above like Cloud SQL and Dataflow.

To get more information about Reservation, see:

» Example Usage - Reservation Basic

resource "google_compute_reservation" "gce_reservation" {
  name = "gce-reservation"
  zone = "us-central1-a"

  specific_reservation {
    count = 1
    instance_properties {
      min_cpu_platform = "Intel Cascade Lake"
      machine_type = "n2-standard-2"
    }
  }
}

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

  • specific_reservation - (Required) Reservation for instances with specific machine shapes. Structure is documented below.

  • zone - (Required) The zone where the reservation is made.

The specific_reservation block supports:

  • count - (Required) The number of resources that are allocated.

  • in_use_count - How many instances are in use.

  • instance_properties - (Required) The instance properties for the reservation. Structure is documented below.

The instance_properties block supports:

The guest_accelerators block supports:

  • accelerator_type - (Required) The full or partial URL of the accelerator type to attach to this instance. For example: projects/my-project/zones/us-central1-c/acceleratorTypes/nvidia-tesla-p100 If you are creating an instance template, specify only the accelerator name.

  • accelerator_count - (Required) The number of the guest accelerator cards exposed to this instance.

The local_ssds block supports:

  • interface - (Optional) The disk interface to use for attaching this disk, one of SCSI or NVME. The default is SCSI.

  • disk_size_gb - (Required) The size of the disk in base-2 GB.


  • description - (Optional) An optional description of this resource.

  • specific_reservation_required - (Optional) When set to true, only VMs that target this reservation by name can consume this reservation. Otherwise, it can be consumed by VMs with affinity for any reservation. Defaults to false.

  • 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:

  • creation_timestamp - Creation timestamp in RFC3339 text format.

  • commitment - Full or partial URL to a parent commitment. This field displays for reservations that are tied to a commitment.

  • status - The status of the reservation.

  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

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

» Import

Reservation can be imported using any of these accepted formats:

$ terraform import google_compute_reservation.default projects/{{project}}/zones/{{zone}}/reservations/{{name}}
$ terraform import google_compute_reservation.default {{project}}/{{zone}}/{{name}}
$ terraform import google_compute_reservation.default {{zone}}/{{name}}
$ terraform import google_compute_reservation.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.