Instance templates


This document describes what an instance template is, when to use an instance template, and what a deterministic instance template is. It also provides a comparison 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, see Create instance templates.

When to use instance templates

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

How to update instance templates

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

Use deterministic instance templates to ensure identical VMs

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

For more information, see Deterministic instance templates.

Regional and global instance templates

Instance templates are available both as regional and global resources. Unless you need to reuse an instance template across multiple regions, Google recommends using regional instance templates over global instance templates.

The following table provides a comparison between regional and global instance templates:

Regional instance template Global instance template
Scope You can use the template only in the template's region. You can use the template in any region.
Reliability Hardware 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 the use of that template to the zone where that resource resides. Similarly, if you specify a regional resource in a global instance template, the template is restricted to that region. For example, if you include a read-only Persistent Disk from us-central1-a in your instance template, you can't use that template in any other zone because that specific Persistent Disk exists only in zone us-central1-a.

For more information about zonal resources, see Regions and zones.

Pricing

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

For Compute Engine pricing information, see Pricing.

What's next