Skip to main content

GCP Compute Instance Template

A GCP Compute Instance Template is a reusable blueprint that captures all the configuration needed to launch a Compute Engine virtual machine—machine type, disks, images, network interfaces, metadata, service accounts, and more. It enables you to create identical VMs individually or via Managed Instance Groups, and to perform rolling updates simply by pointing a group at a new template revision.
Official documentation: https://cloud.google.com/compute/docs/instance-templates

Terrafrom Mappings:

  • google_compute_instance_template.name

Supported Methods

  • GET: Get a gcp-compute-instance-template by its "name"
  • LIST: List all gcp-compute-instance-template
  • SEARCH

gcp-cloud-kms-crypto-key

The template may specify a customer-managed encryption key (CMEK) from Cloud KMS for encrypting the boot or attached disks, creating a dependency on the corresponding crypto-key.

gcp-compute-instance

Every VM that is launched from the template—manually or by a Managed Instance Group—references the template as its source definition.

gcp-compute-security-policy

If instances created from the template are placed behind a backend service or NEG that has a Compute Security Policy (Cloud Armor) attached, the template is indirectly related to that security policy.

gcp-compute-image

The boot disk in the template is typically created from a Compute Engine image, linking the template to that image resource.

gcp-compute-subnetwork

Network interfaces defined in the template can target specific subnetworks, establishing a direct relationship.

gcp-compute-network

When the template specifies a VPC network (or inherits one via a subnetwork), that network is linked to the template.

ip

The template may reserve internal or external IP addresses for its network interfaces; those addresses are represented by the generic ip type.

gcp-iam-service-account

The service account specified in the template’s serviceAccounts block provides the runtime identity for instances, creating a dependency on the chosen IAM service account.

gcp-compute-reservation

Through reservationAffinity, a template can request capacity from a specific reservation, linking the template to that reservation.

gcp-compute-node-group

If the template includes nodeAffinities, it targets sole-tenant node groups for placement, thereby relating the template to the selected node group.

gcp-compute-disk

In addition to the boot disk, the template can attach existing persistent disks; each referenced disk is linked to the template.

gcp-compute-snapshot

A disk initialised from a snapshot instead of an image will link the template to the corresponding snapshot resource.