Create a MIG in a single zone

This document describes how to create amanaged instance group (MIG)in a single zone. Putting all your MIG's VMs in a single zone helps to minimizelatency, which is useful for certain workloads—for example, batch workloads.

This type of MIG is also known as azonal MIG.

You can also read about otherbasic scenarios for creating a MIG.

Before you begin

Limitations

To see the full list of MIG limitations, which varies based on the configurationthat you use, seeMIG limitations.

Create a MIG in a single zone

To create a MIG in a single zone, use theGoogle Cloud console, thegcloud CLI,Terraform, orREST.

Permissions required for this task

To perform this task, you must have the followingpermissions:

Console

  1. In the Google Cloud console, go to theInstance groups page.

    Go to Instance groups

    The remaining steps appear in the Google Cloud console.

  2. ClickCreate instance group.
  3. If you want to create a stateful MIG, select theNew managed instance group (stateful) option. To help you decide, seeWhen to use stateful MIGs.
  4. Assign a name and optionally a description to your instance group.
  5. Choose an instance template for the instance group orcreate a new one.
  6. Specify thenumber of VMs for this group. Remember toprovision enough VMs to support your application if a zone failure happens.
  7. ForLocation, selectSingle zone.
  8. Select theRegion and theZone where you want to create your MIG. If you chose a regional instance template, then theRegion is automatically selected based on the template's region.
  9. For stateless MIGs,Autoscaling is enabled by default. With autoscaling, your groupautomatically adds or removes instances based on its utilization.
  10. Optionally, enableautohealing to perform application-based health checking on VMs within the group.
  11. ClickCreate to create the new group.

gcloud

If you haven't already created an instance template, which specifies themachine type, boot disk image, network, and other VM properties that youwant for each VM in your MIG,create an instance template.

Create a managed instance group with theinstance-groups managed create commandand specify the group name, group size, instance template, and zone.

gcloud compute instance-groups managed createINSTANCE_GROUP_NAME \    --sizeSIZE \    --templateINSTANCE_TEMPLATE_URL \    --zoneZONE

Replace the following:

  • INSTANCE_GROUP_NAME: the name for thisinstance group.
  • SIZE: the size of the instance group.
  • INSTANCE_TEMPLATE_URL: the URL of the instance template that you want touse to create VMs in the MIG. The URL can contain either theIDor name of the instance template. Specify one of the following values:
    • For a regional instance template:projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_ID
    • For a global instance template:INSTANCE_TEMPLATE_ID
  • ZONE: one of thezones available forCompute Engine. If you want to distribute your MIG's VMs acrossmultiple zones in a region, seeCreate a regional MIG.

You can optionally supply the--base-instance-name flag. Because theseVMs are based on a common template, each VM is assigned a random string aspart of its VM name. The base name is prepended to this random string. Forexample, if you set the base name totest, VMs will have names liketest-yahs andtest-qtyz. If you need specific names, seeCreating instances with specific names in MIGs.

For example, the following command creates an instance group namedexample-group, with base VM nametest. The group contains threeinstances:

gcloud compute instance-groups managed create example-group \    --base-instance-name test \    --size 3 \    --template an-instance-template \    --zone us-central1-f

Terraform

If you haven't already created an instance template, which specifies themachine type, boot disk image, network, and other VM properties that youwant for each VM in your MIG,create an instance template.

To create a zonal MIG, you can use thegoogle_compute_instance_group_managerresource.

resource "google_compute_instance_group_manager" "default" {  name               = "example-group"  base_instance_name = "test"  target_size        = 3  zone               = "us-central1-f"  version {    instance_template = google_compute_instance_template.default.id    name              = "primary"  }}

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

REST

If you haven't already created an instance template, which specifies themachine type, boot disk image, network, and other VM properties that youwant for each VM in your MIG,create an instance template.

Create a managed instance group with theinstanceGroupManagers.insert method.In the request body, include the group name, group size,and the URL to the instance template.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers{  "versions": [    {      "instanceTemplate": "INSTANCE_TEMPLATE_URL"    }  ],  "name": "INSTANCE_GROUP_NAME",  "targetSize":SIZE}

Replace the following:

  • PROJECT_ID: the project ID for the request.
  • ZONE: thezone for the request. If youwant to distribute your MIG's VMs across multiple zones in a region,replacezones/ZONE withregions/REGION and specify a region. For moreinformation, seeCreate a regional MIG.
  • INSTANCE_GROUP_NAME: the name for thisinstance group.
  • SIZE: the size of the instance group.
  • INSTANCE_TEMPLATE_URL: the URL of the instance template that you want touse to create VMs in the MIG. The URL can contain either theIDor name of the instance template. Specify one of the following values:
    • For a regional instance template:projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_ID
    • For a global instance template:INSTANCE_TEMPLATE_ID

You can optionally supply thebase-name field. Because theseVMs are based on a common template, each VM is assigned a random string aspart of its VM name. The base name is prepended to this random string. Forexample, if you set the base name totest, VMs will have names liketest-yahs andtest-qtyz. If you need specific names, seeCreating instances with specific names in MIGs.

Depending on how you configure and act on a MIG, various policies and actionscan affect the instances in the group. To determine which managedinstances are up and running, seeChecking the status of managed instances.

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-02 UTC.