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:
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"
}
}
}
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
-
(Output)
How many instances are in use.
instance_properties
-
(Required)
The instance properties for the reservation.
Structure is documented below.
The instance_properties
block supports:
machine_type
-
(Required)
The name of the machine type to reserve.
min_cpu_platform
-
(Optional)
The minimum CPU platform for the reservation. For example,
"Intel Skylake"
. See
the CPU platform availability reference](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#availablezones)
for information on available CPU platforms.
guest_accelerators
-
(Optional)
Guest accelerator type and count.
Structure is documented below.
local_ssds
-
(Optional)
The amount of local ssd to reserve with each instance. This
reserves disks of type local-ssd
.
Structure is documented below.
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.
Default value is SCSI
.
Possible values are: SCSI
, NVME
.
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.
share_settings
-
(Optional)
The share setting for reservations.
Structure is documented below.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
The share_settings
block supports:
share_type
-
(Optional)
Type of sharing for this shared-reservation
Possible values are: LOCAL
, SPECIFIC_PROJECTS
.
project_map
-
(Optional)
A map of project number and project config. This is only valid when shareType's value is SPECIFIC_PROJECTS.
Structure is documented below.
The project_map
block supports:
id
- (Required) The identifier for this object. Format specified above.
project_id
-
(Optional)
The project id/number, should be same as the key of this project config in the project map.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/zones/{{zone}}/reservations/{{name}}
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.This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.Reservation can be imported using any of these accepted formats:
projects/{{project}}/zones/{{zone}}/reservations/{{name}}
{{project}}/{{zone}}/{{name}}
{{zone}}/{{name}}
{{name}}
In Terraform v1.5.0 and later, use an import
block to import Reservation using one of the formats above. For example:
import {
id = "projects/{{project}}/zones/{{zone}}/reservations/{{name}}"
to = google_compute_reservation.default
}
When using the terraform import
command, Reservation can be imported using one of the formats above. For example:
$ 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}}
This resource supports User Project Overrides.