Instance templates

Stay organized with collections Save and categorize content based on your preferences.

An instance template is a resource that you can use to create virtual machine (VM) instances and managed instance groups (MIGs).

Instance templates define the machine type, boot disk image or container image, labels, startup script, and other instance properties. You can then use an instance template to create a MIG or to create individual VMs. Instance templates are a convenient way to save a VM instance's configuration so you can use it later to create VMs or groups of VMs.

An instance template is a global resource that is not bound to a zone or a region. However, you will specify some zonal resources in an instance template, which restricts the template to the zone where that resource resides. 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.

Please note that labels defined within an instance template are applied to all instances that are created from that instance template. The labels do not apply to the instance template itself.

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 VM instances based off of a preexisting configuration. If you want to create a group of identical instances–a managed instance group (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.

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