Instance templates

This document describes what an instance template is, when to use an instancetemplate, and what a deterministic instance template is. It also provides acomparison between regional and global instance templates.

An instance template is a convenient way to save a virtual machine (VM)instance's configuration that includes machine type, boot disk image, labels,startup script, and other VM properties.

You can use an instance template to do the following:

To learn how to create an instance template, seeCreate instance templates.

When to use instance templates

Use instance templates any time you want to quickly create VMs or reservationsfor VMs based off of a pre-existing VM property. If you want to create a groupof identical VMs (a MIG), then you must create the MIG using an instancetemplate.

How to update instance templates

Instance templates are designed to create VMs with identical configurations. Youcan't update instance templates after they're created. Instead, do one of thefollowing:

Use deterministic instance templates to ensure identical VMs

Deterministic instance templates make explicitly clear the type of third-partyservices or apps to install on your VMs. This helps to ensure that your instancetemplate always creates VMs with an identical configuration. For example, if yourtemplate has a startup script that fetches an app, you can specify the versionof the app that you want in your template's startup script.

For more information, seeDeterministic instance templates.

Regional and global instance templates

Instance templates are available both asregionalandglobal resources.Unless you need to reuse an instance template across multiple regions, Googlerecommends using regional instance templates over global instance templates.

The following table provides a comparison between regional and global instancetemplates:

Regional instance templateGlobal instance template
ScopeYou can use the template only in the template's region.You can use the template in any region.
ReliabilityHardware errors are isolated to the template's region.Hardware errors can impact any region where the template is used.
Use case
  • Reduce cross-region dependency.
  • Achieve data residency in a region. For example, to meet compliance requirements on the physical location of the data.
Reuse your global instance template to create VMs, MIGs, and reservations across multiple regions.

Use of zonal or regional resources in instance templates

In an instance template, you might specify zonal resources, which restricts theuse of that template to the zone where that resource resides. Similarly, if youspecify a regional resource in a global instance template, the template isrestricted to that region. For example, if you include a read-only Persistent Diskfromus-central1-a in your instance template, you can't use that template inany other zone because that specific Persistent Disk exists only in zoneus-central1-a.

For more information about zonal resources, seeRegions and zones.

How to specify instance templates

When creating resources that are based on an instance template, depending on theinterface that you're using, you might need to specify the full orpartial URL of the instance template—for example:

  • Full URL:https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/instanceTemplates/1234567890
  • Partial URL:projects/example-project/regions/us-central1/instanceTemplates/1234567890

You can specify either the ID or the name of the instance template. Googlerecommends that you specify the ID because, unlike names, instance template IDscan't be reused. This approach helps to ensure that the resources that youcreate from the template have the properties that you intend.

To view the template ID of an instance, seeGet information about an instance template.

Pricing

There is no additional charge for using instance templates. You are chargedfor the resources that you create based on the templates.

ForCompute Engine pricing information, seePricing.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.