Create resize requests in a MIG

This document explains how to create resize requests in a managed instancegroup (MIG) of virtual machine (VM) instances. To learn more about MIG resizerequests, seeAbout resize requests in a MIG.

Creating a MIG resize request helps you obtain highly-demanded resources, likeGPUs, and optimize costs by creating the exact number of VMs all at once. Tocreate a MIG resize request that can use the features and services availablefrom AI Hypercomputer, see insteadCreate a MIG and a resize requestin the AI Hypercomputer documentation.

Before you begin

Required roles

To get the permissions that you need to create MIG resize requests, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.

This predefined role contains the permissions required to create MIG resize requests. To see the exact permissions that are required, expand theRequired permissions section:

Required permissions

The following permissions are required to create MIG resize requests:

  • To create an instance template: compute.instanceTemplates.create on the project
  • To create a zonal MIG: compute.instanceGroupManagers.create on the project
  • To create a MIG resize request: compute.instanceGroupManagers.update on the project

You might also be able to get these permissions withcustom roles or otherpredefined roles.

Prepare a MIG for resize requests

To create a MIG resize requests, you must configure an instance template and theMIG as described in the following sections.

Create an instance template

Based on your use case for MIG resize requests, create an instance template byusing one of the following methods:

Use the flex-start provisioning model

To create an instance template configured for creating MIG resize requests andFlex-start VMs, you must specify the following settings in thetemplate:

Note: If you want to run data science or machine learning workloads, thenconsider using a Deep Learning VM Images image when you create an instancetemplate. Deep Learning VM is a set of prepackaged VM images thatcomes with machine learning frameworks and essential tools. For more informationabout these images, seeChoose an image in theDeep Learning VM documentation.

To create an instance template, select one of the following options:

Console

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

    Go to Instance templates

  2. ClickCreate instance template. TheCreate an instance templatepage opens.

  3. In theName field, enter a name for the instance template.

  4. In theLocation section, select one of the following options:

    • To create a regional instance template, selectRegional (recommended), and then select the region in which tocreate the template.

    • To create a global instance template, selectGlobal.

  5. In theMachine configuration section, specify a GPU machine type oran H4D machine type.

  6. In theProvisioning model section, complete the following steps:

    1. In theVM provisioning model field, selectFlex-start.

    2. ExpandVM provisioning model advanced settings.

    3. Select theSet a time limit for the VM checkbox.

    4. To set a run duration for the VMs created through the instancetemplate, in theEnter number of hours field, enter thenumber of hours. The value must be between 36 seconds (0.01) andseven days (168).

  7. Optional: To change the default value boot disk type or image, in theBoot disk section, clickChange. Then, follow the prompts tochange the boot disk.

  8. ClickCreate.

gcloud

To create an instance template, use theinstance-templates create commandwith the following flags:

  • The--instance-termination-action flag set toDELETE.

  • The--maintenance-policy flag set toTERMINATE.

  • The--max-run-duration flag.

  • The--provisioning-model flag set toFLEX_START.

  • The--reservation-affinity flag set tonone.

For example, to create a regional instance template, run the followingcommand. If you want to create a global instance template, then use the samecommand without the--instance-template-region flag.

gcloud compute instance-templates createINSTANCE_TEMPLATE_NAME \    --image-project=IMAGE_PROJECT \    --image-family=IMAGE_FAMILY \    --instance-template-region=REGION \    --instance-termination-action=DELETE \    --machine-type=MACHINE_TYPE \    --maintenance-policy=TERMINATE \    --max-run-duration=RUN_DURATION \    --provisioning-model=FLEX_START \    --reservation-affinity=none

Replace the following:

REST

To create an instance template, make aPOST request to one of thefollowing methods:

In the request body, include the following fields:

  • ThereservationAffinity.consumeReservationType field set toNO_RESERVATION.

  • Thescheduling.instanceTerminationAction field set toDELETE.

  • Thescheduling.maxRunDuration field.

  • Thescheduling.onHostMaintenance field set toTERMINATE.

  • Thescheduling.provisioningModel field set toFLEX_START.

For example, to create a regional instance template, make a request asfollows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates{  "name": "INSTANCE_TEMPLATE_NAME",  "properties": {    "disks": [      {        "boot": true,        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        }      }    ],    "machineType": "MACHINE_TYPE",    "networkInterfaces": [      {        "network": "global/networks/default"      }    ],    "reservationAffinity": {      "consumeReservationType": "NO_RESERVATION"    },    "scheduling": {      "instanceTerminationAction": "DELETE",      "maxRunDuration": {        "seconds":RUN_DURATION      },      "onHostMaintenance": "TERMINATE",      "provisioningModel": "FLEX_START"    }  }}

Replace the following:

  • PROJECT_ID: the ID of the project in which to createthe instance template.

  • REGION: the region in which to create the instancetemplate.

  • INSTANCE_TEMPLATE_NAME: the name of the instancetemplate to create.

  • IMAGE_PROJECT: the image project that contains theimage; for example,debian-cloud. For more information about thesupported image projects, seePublic images.

  • IMAGE: specify one of the following:

    • A specific version of the OS image—for example,debian-12-bookworm-v20240617.

    • Animage family, which must beformatted asfamily/IMAGE_FAMILY. This specifiesthe most recent, non-deprecated OS image. For example, if youspecifyfamily/debian-12, the latest version in the Debian 12image family is used. For more information about using imagefamilies, seeImage families best practices.

  • MACHINE_TYPE: the GPU machine type to use for theVMs. If you specify an N1 machine type, then you must include theguestAccelerators fieldto define the number and type of GPUs to attach to your VMs.

  • RUN_DURATION: the duration, in seconds, you want therequested VMs to run. The value must be between600, which is 600seconds (10 minutes), and604800, which is 604,800 seconds (sevendays).

For more information about creating an instance template, seeCreate instance templates.

Use the reservation-bound provisioning model

To create an instance template configured for MIG resize requests and forconsuming a reservation, you must specify the following in the template:

Note: If you want to run data science or machine learning workloads, thenconsider using a Deep Learning VM Images image when you create an instancetemplate. Deep Learning VM is a set of prepackaged VM images thatcomes with machine learning frameworks and essential tools. For more informationabout these images, seeChoose an image in theDeep Learning VM documentation.

To create an instance template, select one of the following options:

Console

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

    Go to Instance templates

  2. ClickCreate instance template. TheCreate an instance templatepage opens.

  3. In theName field, enter a name for the instance template.

  4. In theLocation section, select one of the following options:

    • To create a regional instance template, selectRegional (recommended), and then select the region in which tocreate the template.

    • To create a global instance template, selectGlobal.

  5. In theMachine configuration section, specify an A4, A3 Ultra, orH4D machine type.

  6. In theProvisioning model section, complete the following steps:

    1. ExpandVM provisioning model advanced settings.

    2. In theOn VM termination list, selectDelete.

  7. Optional: To change the default value boot disk type or image, in theBoot disk section, clickChange. Then, follow the prompts tochange the boot disk.

  8. Expand theAdvanced options section, and then do thefollowing:

    1. Expand theManagement section.

    2. In theReservations section, selectChoose a reservation,and then clickChoose reservation. In the pane that appears,follow the prompts to select the reservation that you want toconsume.

  9. ClickCreate.

gcloud

To create an instance template, use theinstance-templates create commandwith the following flags:

  • The--instance-termination-action flag set toDELETE.

  • The--maintenance-policy flag set toTERMINATE.

  • The--provisioning-model flag set toRESERVATION_BOUND.

  • The--reservation-affinity flag set tospecific.

  • The--reservation flag.

For example, to create a regional instance template, run the followingcommand. If you want to create a global instance template, then use the samecommand without the--instance-template-region flag.

gcloud compute instance-templates createINSTANCE_TEMPLATE_NAME \    --image-project=IMAGE_PROJECT \    --image-family=IMAGE_FAMILY \    --instance-termination-action=DELETE \    --instance-template-region=REGION \    --machine-type=MACHINE_TYPE \    --maintenance-policy=TERMINATE \    --provisioning-model=RESERVATION_BOUND \    --reservation-affinity=specific \    --reservation=RESERVATION_URL

Replace the following:

REST

To create an instance template, make aPOST request to one of thefollowing methods:

In the request body, include the following fields:

  • ThereservationAffinity.consumeReservationType field set toSPECIFIC_RESERVATION.

  • ThereservationAffinity.key field set tocompute.googleapis.com/reservation-name.

  • ThereservationAffinity.values field set to the URL of theauto-created reservation.

  • Thescheduling.instanceTerminationAction field set toDELETE.

  • Thescheduling.onHostMaintenance field set toTERMINATE.

  • Thescheduling.provisioningModel field set toRESERVATION_BOUND.

For example, to create a regional instance template, make a request asfollows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates{  "name": "INSTANCE_TEMPLATE_NAME",  "properties": {    "disks": [      {        "boot": true,        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        }      }    ],    "machineType": "MACHINE_TYPE",    "networkInterfaces": [      {        "network": "global/networks/default"      }    ],    "reservationAffinity": {      "consumeReservationType": "SPECIFIC_RESERVATION",      "key": "compute.googleapis.com/reservation-name",      "values": [        "RESERVATION_URL"      ]    },    "scheduling": {      "instanceTerminationAction": "DELETE",      "onHostMaintenance": "TERMINATE",      "provisioningModel": "RESERVATION_BOUND"    }  }}

Replace the following:

  • PROJECT_ID: the ID of the project in which to createthe instance template.

  • REGION: the region in which to create the instancetemplate.

  • INSTANCE_TEMPLATE_NAME: the name of the instancetemplate to create.

  • IMAGE_PROJECT: the image project that contains theimage; for example,debian-cloud. For more information about thesupported image projects, seePublic images.

  • IMAGE: specify one of the following:

    • A specific version of the OS image—for example,debian-12-bookworm-v20240617.

    • Animage family, which must beformatted asfamily/IMAGE_FAMILY. This specifiesthe most recent, non-deprecated OS image. For example, if youspecifyfamily/debian-12, the latest version in the Debian 12image family is used. For more information about using imagefamilies, seeImage families best practices.

  • MACHINE_TYPE: the A4 or A3 Ultra machine type that isspecified in the reservation that you want to consume.

  • RESERVATION_URL: the URL of the auto-createdreservation for a future reservation in calendar mode that you want toconsume. Specify one of the following values:

    • If the auto-created reservation exists in your project:RESERVATION_NAME

    • If the auto-created reservation exists in a different project:projects/PROJECT_ID/reservations/RESERVATION_NAME

For more information about creating an instance template, seeCreate instance templates.

Create or update a MIG

After creating the instance template as described in the previous section, usethat instance template to create a MIG as follows, orupdate a MIG.Additionally, you must do the following to prepare the MIG for resize requests:

Note: When you create a MIG using the Google Cloud console, you can alsocreate a resize request in the MIG at the same time. Otherwise, if you want touse the gcloud CLI or REST, you must create a MIG as follows,and thencreate a resize request in the MIG as described inthe next section.

To create a MIG that is compatible with resize requests, select one of thefollowing options:

Console

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

    Go to Instance groups

  2. ClickCreate instance group. TheCreate instance group pageopens.

  3. In theName field, enter a name for the MIG.

  4. Before you select an instance template, you must delete the autoscalingconfiguration and turn off repairs as follows:

    1. To delete the autoscaling configuration, do the following:

      1. In theAutoscaling section, click theAutoscaling modelist, and then clickDelete autoscaling configuration.

      2. In the confirmation dialog, clickDelete.

    2. To turn off repairs, in theVM instance lifecycle section, clicktheDefault action on failure list, and then selectNo action.

  5. Go back to theInstance template field. In theInstance templatelist, select the instance template that you created in the previoussection. If you select a regional instance template, then theRegionlist is set to the template's region.

  6. Do one of the following:

    • To create a resize request when you create the MIG, do thefollowing:

      1. In theNumber of instances field, enter the number of VMsthat you want to create all at once.

      2. Select theUse resize request to create VMs all at oncecheckbox.

      3. Optional: If the MIG's instance template specifies a runduration, then you can specify a different run duration. To doso, in theRequested run duration field andUnit lists,specify a run duration. You must specify a duration between onehour and seven days.

    • To create a resize request after you create the MIG, in theNumber of instances field, enter0.

  7. In theLocation section, specify whether you want to create a zonalor a regional MIG as follows:

    1. To create a zonal MIG, selectSingle zone. Or, to create aregional MIG, selectMultiple zones.

    2. Select theRegion andZones of the MIG.

    3. If you're creating a regional MIG, then do the following:

      1. In theTarget distribution shape field, selectAny single zone.

      2. In the dialog that appears, clickDisable instance redistribution.

  8. ClickCreate.

gcloud

Use theinstance-groups managed create commandwith the--default-action-on-vm-failure flag set todo_nothing. Ifyou're creating a regional MIG, then you must also include the--target-distribution-shape flag set toany-single-zone, andthe--instance-redistribution-type flag set tonone.

  • To create a zonal MIG, run the following command:

    gcloud compute instance-groups managed createINSTANCE_GROUP_NAME \    --template=INSTANCE_TEMPLATE_URL \    --size=0 \    --zone=ZONE \    --default-action-on-vm-failure=do_nothing
  • To create a regional MIG, run the following command:

    gcloud compute instance-groups managed createINSTANCE_GROUP_NAME \    --template=INSTANCE_TEMPLATE_URL \    --size=0 \    --region=REGION \    --target-distribution-shape=any-single-zone \    --instance-redistribution-type=none \    --default-action-on-vm-failure=do_nothing

Replace the following:

  • INSTANCE_GROUP_NAME: the name of the MIG to create.

  • INSTANCE_TEMPLATE_URL: the partial URL of theinstance template that you created in the previous section. If youwant to use a regional instance template to create the MIG, then you canonly create the MIG within the template's region. Specify oneof the following values:

    • For a regional instance template:projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_NAME

    • For a global instance template:INSTANCE_TEMPLATE_NAME

  • ZONE: the zone in which to create the MIG.

  • REGION: the region in which to create the MIG.

REST

  • To create a zonal MIG, send aPOST request using theinstanceGroupManagers.insert methodas follows:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers{  "versions": [    {      "instanceTemplate": "INSTANCE_TEMPLATE_URL"    }  ],  "name": "INSTANCE_GROUP_NAME",  "targetSize": 0,  "instanceLifecyclePolicy": {    "defaultActionOnFailure": "DO_NOTHING"  }}
  • To create a regional MIG, send aPOST request using theregionInstanceGroupManagers.insert methodas follows:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceGroupManagers{  "versions": [    {      "instanceTemplate": "INSTANCE_TEMPLATE_URL"    }  ],  "name": "INSTANCE_GROUP_NAME",  "targetSize": 0,  "distributionPolicy": {    "targetShape": "ANY_SINGLE_ZONE"  },  "updatePolicy": {    "instanceRedistributionType": "NONE"  },  "instanceLifecyclePolicy": {    "defaultActionOnFailure": "DO_NOTHING"  }}

Replace the following:

  • PROJECT_ID: the ID of the project where the instancetemplate that you created in the previous section exists.

  • INSTANCE_TEMPLATE_URL: the partial URL of theinstance template that you created in the previous section. If youwant to use a regional instance template to create the MIG, then you canonly create the MIG within the template's region. Specify oneof the following values:

    • For a regional instance template:regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_NAME

    • For a global instance template:global/instanceTemplates/INSTANCE_TEMPLATE_NAME

  • ZONE: the zone in which to create the MIG.

  • REGION: the region in which to create the MIG.

  • INSTANCE_GROUP_NAME: the name of the MIG to create.

Create a resize request in a MIG

Preview — Resize requests in regional MIGs and resize request creation by specifying VM names in zonal and regional MIGs.

These features are subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

Before you create MIG resize requests, make sure that you'veprepared the MIG as described in the previous section.

After you create a resize request and all your requested resources becomeavailable, the MIG creates the requested number of VMs all at once. The VMs rununtil the MIG deletes them after the specified run duration ends, or until youdelete them.

To create a resize request in a MIG, select one of the following options. To addVMs with specific names to the MIG through a resize request, use thegcloud CLI or REST API.

Console

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

    Go to Instance groups

  2. In theName column, click the name of the MIG in which to create theresize request.

    The overview page of the MIG opens.

  3. In theResize requests row, clickEdit resize requests.

  4. ClickNew resize request.

    TheNew resize requests pane appears.

  5. In theName field, enter the name of the resize request.

  6. In theNumber of additional instances needed field, enter the numberof VMs to add to the MIG all at once.

  7. Optional: If the MIG's instance template specifies a run duration, thenyou can specify a different run duration. To do so, in theRequested run duration field andUnit lists, specify a runduration. You must specify a duration between one hour and seven days.

  8. ClickCreate.

gcloud

Replace the following:

  • INSTANCE_GROUP_NAME: the name of theMIG configured for creating resize requests in it.

  • RESIZE_REQUEST_NAME: the name of the resize request,which must be unique within the specified MIG. Otherwise, creating theresize request fails.

  • COUNT: the number of VMs to add to the MIG all atonce.

  • ZONE: the zone where the MIG exists.

  • REGION: the region where the MIG exists.

Optionally, you can do the following:

REST

In the request body, include the following:

{  "name": "RESIZE_REQUEST_NAME",  "resizeBy":COUNT}

Replace the following:

  • PROJECT_ID: the ID of the project where the specifiedMIG exists.

  • ZONE: the zone where the MIG exists.

  • REGION: the region where the MIG exists.

  • INSTANCE_GROUP_NAME: the name of the MIGconfigured for creating resize requests in it.

  • RESIZE_REQUEST_NAME: the name of the resize request,which must be unique within the specified MIG. Otherwise, creatingthe resize request fails.

  • COUNT: the number of VMs to add all at once to theMIG.

Optionally, you can do the following:

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.