Google Compute Engine Reservation
This page shows how to write Terraform for Compute Engine Reservation and write them securely.
google_compute_reservation (Terraform)
The Reservation in Compute Engine can be configured in Terraform with the resource name google_compute_reservation. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
commitmentoptional computed - string
Full or partial URL to a parent commitment. This field displays for reservations that are tied to a commitment.
-
creation_timestampoptional computed - string
Creation timestamp in RFC3339 text format.
-
descriptionoptional - string
An optional description of this resource.
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?' 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.
-
projectoptional computed - string -
self_linkoptional computed - string -
specific_reservation_requiredoptional - bool
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.
-
statusoptional computed - string
The status of the reservation.
-
zonerequired - string
The zone where the reservation is made.
-
specific_reservationlist block-
countrequired - number
The number of resources that are allocated.
-
in_use_countoptional computed - number
How many instances are in use.
-
instance_propertieslist block-
machine_typerequired - string
The name of the machine type to reserve.
-
min_cpu_platformoptional computed - string
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_acceleratorslist block-
accelerator_countrequired - number
The number of the guest accelerator cards exposed to this instance.
-
accelerator_typerequired - string
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.
-
-
local_ssdslist block-
disk_size_gbrequired - number
The size of the disk in base-2 GB.
-
interfaceoptional - string
The disk interface to use for attaching this disk. Default value: "SCSI" Possible values: ["SCSI", "NVME"]
-
-
-
-
timeoutssingle block
Explanation in Terraform Registry
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-microorg1-smallmachine 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
- How-to Guides
Tips: Best Practices for The Other Google Compute Engine Resources
In addition to the google_compute_disk, Google Compute Engine has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
google_compute_disk
Ensure the encryption key for your GCE disk is stored securely
It is better to store the encryption key for your GCE disk securely. Secret Manager could be used instead.
google_compute_firewall
Ensure your VPC firewall blocks unwanted outbound traffic
It is better to block unwanted outbound traffic not to expose resources in the VPC to unwanted attacks.
google_compute_instance
Ensure appropriate service account is assigned to your GCE instance
It is better to create a custom service account for the instance and assign it.
google_compute_project_metadata
Ensure OS login for your GCE instances is enabled at project level
It is better to enable OS login for your GCE instances. Enabling OS login ensures that SSH keys used to connect to instances are mapped with IAM users, allowing centralized and automated SSH key management.
google_compute_ssl_policy
Ensure to use modern TLS protocols
It's better to adopt TLS v1.2+ instead of outdated TLS protocols.
google_compute_subnetwork
Ensure VPC flow logging is enabled
It is better to enable VPC flow logging. VPC flow logging allows us to audit traffic in your network.