blob: 3de1b5a1cdbca8fee48f144164252cd02e03edad [file] [log] [blame] [edit]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Compute Engine"
description: |-
Represents a reservation resource.
---
# 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:
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/reservations)
* How-to Guides
* [Reserving zonal resources](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=reservation_basic&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Reservation Basic
```hcl
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](#nested_specific_reservation).
* `zone` -
(Required)
The zone where the reservation is made.
<a name="nested_specific_reservation"></a>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](#nested_instance_properties).
<a name="nested_instance_properties"></a>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](#nested_guest_accelerators).
* `local_ssds` -
(Optional)
The amount of local ssd to reserve with each instance. This
reserves disks of type `local-ssd`.
Structure is [documented below](#nested_local_ssds).
<a name="nested_guest_accelerators"></a>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.
<a name="nested_local_ssds"></a>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](#nested_share_settings).
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
<a name="nested_share_settings"></a>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](#nested_project_map).
<a name="nested_project_map"></a>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.
## 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}}/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.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## Import
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](https://developer.hashicorp.com/terraform/language/import) to import Reservation using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/zones/{{zone}}/reservations/{{name}}"
to = google_compute_reservation.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).