This page 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's (VM) configuration that includes machine type, boot disk image, labels, startup script, and other instance properties.
You can use an instance template to do the following:
- Create individual VMs.
- Create VMs in a managed instance group (MIG).
- Create reservations for VMs.
- Create future reservations for VMs.
To learn how to create an instance template, read Creating 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 configuration. If you want to create a group of identical instances–a MIG–you must have an instance template that the group can use.
How to update instance templates
Instance templates are designed to create instances with identical configurations. So you cannot update an existing instance template or change an instance template after you create it.
If you need to make changes to the configuration, create a new instance template. You can create a template based on an existing instance template, or based on an existing instance. You can also override instance template fields when creating a VM instance from an instance template.
Use deterministic instance templates to ensure identical VMs
To ensure that your instance template always create VMs with identical configuration, set explicit properties in your template that reflect the exact configuration that you want. For example, if your template has a startup script that fetches an app, specify the version of the app that you want in your template's startup script. Otherwise your VMs might not get the app version that you expect.
For more information, see Deterministic instance templates.
Regional and global instance templates
Instance templates are available as both regional and global resources. The following table provides a comparison between regional and global instance templates.
Regional instance template | Global instance template | |
---|---|---|
Scope | Can be used in the specified region only. | Can be used in any region. |
Use case |
|
Reuse your instance template to create VMs, MIGs, and reservations in different 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-b
in your instance template, you cannot use that template in any
other zone because that specific disk exists only in zone us-central1-b
. 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
- Create an instance template from scratch, based on an existing instance, or based on an existing instance template.
- Use an instance template to create a VM instance.
- Use an instance template to create a MIG.
- Use an instance template to create a reservation for VMs.