Create resize requests in a MIG Stay organized with collections Save and categorize content based on your preferences.
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
- To use MIG resize requests to create Flex-start VMs for workloads that run for up to seven days, verify that you have sufficient quota for your requested resources. Otherwise, your resize request remains pending until you have sufficient quota.
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
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.createon the project - To create a zonal MIG:
compute.instanceGroupManagers.createon the project - To create a MIG resize request:
compute.instanceGroupManagers.updateon 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:
If you want to create Flex-start VMs for workloads that run for upto seven days, thencreate an instance template by using the flex-start provisioning model.
If you want to create VMs by consuming an auto-created reservation for afuture reservation in calendar mode, thencreate an instance template by using the reservation-bound provisioning model.
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:
Use aGPU machine type (exceptA4X or G4), or anH4D machine type.
Delete VMs at the end of their run duration by using the
maxRunDurationandinstanceTerminationActionfields.Stop VMs duringhost maintenance events.
Use theflex-start provisioning model.
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
In the Google Cloud console, go to theInstance templates page.
ClickCreate instance template. TheCreate an instance templatepage opens.
In theName field, enter a name for the instance template.
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.
In theMachine configuration section, specify a GPU machine type oran H4D machine type.
In theProvisioning model section, complete the following steps:
In theVM provisioning model field, selectFlex-start.
ExpandVM provisioning model advanced settings.
Select theSet a time limit for the VM checkbox.
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).
Optional: To change the default value boot disk type or image, in theBoot disk section, clickChange. Then, follow the prompts tochange the boot disk.
ClickCreate.
gcloud
To create an instance template, use theinstance-templates create commandwith the following flags:
The
--instance-termination-actionflag set toDELETE.The
--maintenance-policyflag set toTERMINATE.The
--max-run-durationflag.The
--provisioning-modelflag set toFLEX_START.The
--reservation-affinityflag 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=noneReplace the following:
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.
Note: If you want to use a specific version of the OS image, such asIMAGE_FAMILY: animage family. This specifies the mostrecent, non-deprecated OS image. For example, if you specifydebian-12, the latest version in the Debian 12 image family is used.For more information about using image families, seeImage families best practices.debian-12-bookworm-v20240701, then replace the--image-familyflagwith the--imageflag.REGION: the region in which to create the instancetemplate.MACHINE_TYPE: the GPU machine type or H4D machinetype to use for the Flex-start VMs. If you specify an N1machine type, then you must include the--acceleratorflagto define the number and type of GPUs to attach to your VMs.RUN_DURATION: the duration you want the requested VMsto run. You must format the value as the number of days, hours, minutes,or seconds followed byd,h,m, andsrespectively. For example,specify30mfor 30 minutes or1d2h3m4sfor one day, two hours, threeminutes, and four seconds. The value must be between 10 minutes andseven days.
REST
To create an instance template, make aPOST request to one of thefollowing methods:
To create a regional instance template:
regionInstanceTemplates.insertmethodTo create a global instance template:
instanceTemplates.insertmethod
In the request body, include the following fields:
The
reservationAffinity.consumeReservationTypefield set toNO_RESERVATION.The
scheduling.instanceTerminationActionfield set toDELETE.The
scheduling.maxRunDurationfield.The
scheduling.onHostMaintenancefield set toTERMINATE.The
scheduling.provisioningModelfield 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 as
family/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 theguestAcceleratorsfieldto 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:
To use anA4 or A3 Ultra machine type,or anH4D machine type,as specified in the reservation that you want to consume.
To stop VMs duringhost maintenance events.
To delete VMs at the end of the reservation period by using the
instanceTerminationActionfield.To use thereservation-bound provisioning model.
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
In the Google Cloud console, go to theInstance templates page.
ClickCreate instance template. TheCreate an instance templatepage opens.
In theName field, enter a name for the instance template.
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.
In theMachine configuration section, specify an A4, A3 Ultra, orH4D machine type.
In theProvisioning model section, complete the following steps:
ExpandVM provisioning model advanced settings.
In theOn VM termination list, selectDelete.
Optional: To change the default value boot disk type or image, in theBoot disk section, clickChange. Then, follow the prompts tochange the boot disk.
Expand theAdvanced options section, and then do thefollowing:
Expand theManagement section.
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.
ClickCreate.
gcloud
To create an instance template, use theinstance-templates create commandwith the following flags:
The
--instance-termination-actionflag set toDELETE.The
--maintenance-policyflag set toTERMINATE.The
--provisioning-modelflag set toRESERVATION_BOUND.The
--reservation-affinityflag set tospecific.The
--reservationflag.
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_URLReplace the following:
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.
Note: If you want to use a specific version of the OS image, such asIMAGE_FAMILY: animage family. This specifies the mostrecent, non-deprecated OS image. For example, if you specifydebian-12, the latest version in the Debian 12 image family is used.For more information about using image families, seeImage families best practices.debian-12-bookworm-v20240701, then replace the--image-familyflagwith the--imageflag.REGION: the region in which to create the instancetemplate.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.
REST
To create an instance template, make aPOST request to one of thefollowing methods:
To create a regional instance template:
regionInstanceTemplates.insertmethodTo create a global instance template:
instanceTemplates.insertmethod
In the request body, include the following fields:
The
reservationAffinity.consumeReservationTypefield set toSPECIFIC_RESERVATION.The
reservationAffinity.keyfield set tocompute.googleapis.com/reservation-name.The
reservationAffinity.valuesfield set to the URL of theauto-created reservation.The
scheduling.instanceTerminationActionfield set toDELETE.The
scheduling.onHostMaintenancefield set toTERMINATE.The
scheduling.provisioningModelfield 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 as
family/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_NAMEIf 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:
If you've configured autoscaling in the MIG, thendelete the autoscaling configuration.
If you're using a regional MIG, thenset the target distribution shapeto
ANY_SINGLE_ZONE.
To create a MIG that is compatible with resize requests, select one of thefollowing options:
Console
In the Google Cloud console, go to theInstance groups page.
ClickCreate instance group. TheCreate instance group pageopens.
In theName field, enter a name for the MIG.
Before you select an instance template, you must delete the autoscalingconfiguration and turn off repairs as follows:
To delete the autoscaling configuration, do the following:
In theAutoscaling section, click theAutoscaling modelist, and then clickDelete autoscaling configuration.
In the confirmation dialog, clickDelete.
To turn off repairs, in theVM instance lifecycle section, clicktheDefault action on failure list, and then selectNo action.
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.
Do one of the following:
To create a resize request when you create the MIG, do thefollowing:
In theNumber of instances field, enter the number of VMsthat you want to create all at once.
Select theUse resize request to create VMs all at oncecheckbox.
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, enter
0.
In theLocation section, specify whether you want to create a zonalor a regional MIG as follows:
To create a zonal MIG, selectSingle zone. Or, to create aregional MIG, selectMultiple zones.
Select theRegion andZones of the MIG.
If you're creating a regional MIG, then do the following:
In theTarget distribution shape field, selectAny single zone.
In the dialog that appears, clickDisable instance redistribution.
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_nothingTo 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_NAMEFor 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 a
POSTrequest using theinstanceGroupManagers.insertmethodas 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 a
POSTrequest using theregionInstanceGroupManagers.insertmethodas 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_NAMEFor 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
In the Google Cloud console, go to theInstance groups page.
In theName column, click the name of the MIG in which to create theresize request.
The overview page of the MIG opens.
In theResize requests row, clickEdit resize requests.
ClickNew resize request.
TheNew resize requests pane appears.
In theName field, enter the name of the resize request.
In theNumber of additional instances needed field, enter the numberof VMs to add to the MIG all at once.
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.
ClickCreate.
gcloud
To create a resize request in a zonal MIG, use the
instance-groups managed resize-requests createcommand.gcloud compute instance-groups managed resize-requests createINSTANCE_GROUP_NAME \ --resize-request=RESIZE_REQUEST_NAME \ --resize-by=COUNT \ --zone=ZONETo create a resize request in a regional MIG, use the
beta instance-groups managed resize-requests createcommand.gcloud beta compute instance-groups managed resize-requests createINSTANCE_GROUP_NAME \ --resize-request=RESIZE_REQUEST_NAME \ --resize-by=COUNT \ --region=REGION
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:
If the MIG's instance template specifies a run duration, then you canspecify a different run duration. To do so, include the
--requested-run-durationflagin the command. You must specify a duration between 10 minutes and sevendays.If your workload requires specific VM names, then you can specify a listof names of VMs to create by using the
beta instance-groups managed resize-requests createcommand.In the command, replace the--resize-requestflag with the--instancesflag.
REST
To create a resize request in a zonal MIG, send a
POSTrequest usingtheinstanceGroupManagerResizeRequests.insertmethod.POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/INSTANCE_GROUP_NAME/resizeRequestsTo create a resize request in a regional MIG, send a
POSTrequestusing thebeta.regionInstanceGroupManagerResizeRequests.insertmethod.
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:
If the MIG's instance template specifies a run duration, then you canspecify a different run duration. To do so, include the
requestedRunDurationfieldin the request body. You must specify a duration, in seconds, between 10minutes and seven days.If your workload requires specific VM names, then you can specify a listof names of VMs to create. To do so, send a
POSTrequest to thebeta.regionInstanceGroupManagerResizeRequests.insertmethodfor a regional MIG, or thebeta.instanceGroupManagerResizeRequests.insertmethodfor a zonal MIG. In the request body, replace theresizeByfield withtheinstanceNamesfield.
What's next
Learn how toview, cancel, or delete resize requests in a MIG.
Learn how toview info about MIGs and managed VMs.
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.