gcloud alpha compute instance-groups managed create Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha compute instance-groups managed create - create a Compute Engine managed instance group
- SYNOPSIS
gcloud alpha compute instance-groups managed createNAME--size=SIZE--template=TEMPLATE[--action-on-vm-failed-health-check=ACTION_ON_FAILED_HEALTH_CHECK][--base-instance-name=BASE_INSTANCE_NAME][--default-action-on-vm-failure=ACTION_ON_VM_FAILURE][--description=DESCRIPTION][--[no-]force-update-on-repair][--initial-delay=INITIAL_DELAY][--instance-redistribution-type=TYPE][--instance-selection=name=NAME,machine-type=MACHINE_TYPE[,machine-type=MACHINE_TYPE…][,rank=RANK]][--instance-selection-machine-types=[MACHINE_TYPE,…]][--list-managed-instances-results=MODE][--on-repair-allow-changing-zone=ON_REPAIR_ALLOW_CHANGING_ZONE][--resource-manager-tags=[KEY=VALUE,…]][--standby-policy-initial-delay=STANDBY_POLICY_INITIAL_DELAY][--standby-policy-mode=STANDBY_POLICY_MODE][--stateful-disk=[auto-delete=AUTO-DELETE],[device-name=DEVICE-NAME]][--stateful-external-ip=[enabled],[auto-delete=AUTO-DELETE],[interface-name=INTERFACE-NAME]][--stateful-internal-ip=[enabled],[auto-delete=AUTO-DELETE],[interface-name=INTERFACE-NAME]][--stopped-size=STOPPED_SIZE][--suspended-size=SUSPENDED_SIZE][--target-distribution-shape=SHAPE][--target-pool=[TARGET_POOL,…]][--target-size-policy-mode=TARGET_SIZE_POLICY_MODE][--workload-policy=WORKLOAD_POLICY][--zones=ZONE,[ZONE,…]][--health-check=HEALTH_CHECK|--http-health-check=HTTP_HEALTH_CHECK|--https-health-check=HTTPS_HEALTH_CHECK][--region=REGION|--zone=ZONE][--update-policy-max-surge=MAX_SURGE--update-policy-max-unavailable=MAX_UNAVAILABLE--update-policy-min-ready=MIN_READY--update-policy-minimal-action=UPDATE_POLICY_MINIMAL_ACTION--update-policy-most-disruptive-action=UPDATE_POLICY_MOST_DISRUPTIVE_ACTION--update-policy-replacement-method=UPDATE_POLICY_REPLACEMENT_METHOD--update-policy-type=UPDATE_TYPE][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)gcloud alpha compute instance-groups managedcreatecreates a Compute Engine managed instance group.- EXAMPLES
- Running:
gcloudalphacomputeinstance-groupsmanagedcreateexample-managed-instance-group--zone=us-central1-a--template=example-global-instance-template--size=1will create a managed instance group called 'example-managed-instance-group' inthe
zone with a globalinstance template resource 'example-global-instance-template'.us-central1-aTo use a regional instance template, specify the full or partial URL of thetemplate.
Running:
gcloudalphacomputeinstance-groupsmanagedcreateexample-managed-instance-group--zone=us-central1-a--template=projects/example-project/regions/us-central1/instanceTemplates/example-regional-instance-template--size=1will create a managed instance group called 'example-managed-instance-group' inthe
zone with a regionalinstance template resource 'example-regional-instance-template'.us-central1-a - POSITIONAL ARGUMENTS
NAME- Name of the managed instance group to create.
- REQUIRED FLAGS
--size=SIZE- Initial number of instances you want in this group.
--template=TEMPLATE- Specifies the instance template to use when creating new instances. An instancetemplate is either a global or regional resource.
- OPTIONAL FLAGS
--action-on-vm-failed-health-check=ACTION_ON_FAILED_HEALTH_CHECK- Specifies the action that a MIG performs on an unhealthy VM. A VM is marked asunhealthy when the application running on that VM fails a health check. Bydefault, the value of the flag is set to
.default-actionACTION_ON_FAILED_HEALTH_CHECKmust be one of:default-action- (Default) MIG uses the same action configured for the defaultActionOnFailurefield.
do-nothing- MIG does not repair an unhealthy VM.
repair- MIG automatically repairs an unhealthy VM by recreating it.
--base-instance-name=BASE_INSTANCE_NAME- Base name to use for the Compute Engine instances that will be created with themanaged instance group. If not provided base instance name will be the prefix ofinstance group name.
--default-action-on-vm-failure=ACTION_ON_VM_FAILURE- Specifies the action that a MIG performs on a failed VM. If the value of theonFailedHealthCheck field is
DEFAULT_ACTION, then the same actionalso applies to the VMs on which your application fails a health check. Bydefault, the value of the flag is set to.repairACTION_ON_VM_FAILUREmust be one of:repair- (Default) MIG automatically repairs a failed VM by recreating it.
do-nothing- MIG does not repair a failed VM.
delete- MIG deletes a failed VM. Deleting the VM decreases the target size of the MIG.
--description=DESCRIPTION- An optional description for this group.
--[no-]force-update-on-repair- Specifies whether to apply the group's latest configuration when repairing a VM.If you updated the group's instance template or per-instance configurationsafter the VM was created, then these changes are applied when VM is repaired. Ifthis flag is disabled with
, then updatesare applied in accordance with the group's update policy type. By default, thisflag is disabled. Use-no-force-update-on-repair--force-update-on-repairto enable and--no-force-update-on-repairto disable. --initial-delay=INITIAL_DELAY- Specifies the number of seconds that a new VM takes to initialize and run itsstartup script. During a VM's initial delay period, the MIG ignores unsuccessfulhealth checks because the VM might be in the startup process. This prevents theMIG from prematurely recreating a VM. If the health check receives a healthyresponse during the initial delay, it indicates that the startup process iscomplete and the VM is ready. The value of initial delay must be between 0 and3600 seconds. The default value is 0. See $gcloud topic datetimes forinformation on duration formats.
--instance-redistribution-type=TYPE- Specifies the type of the instance redistribution policy. An instanceredistribution type lets you enable or disable automatic instance redistributionacross zones to meet the group's target distribution shape.
An instance redistribution type can be specified only for a non-autoscaledregional managed instance group. By default it is set to
.proactiveTYPEmust be one of:none- The managed instance group does not redistribute instances across zones.
proactive- The managed instance group proactively redistributes instances to meet itstarget distribution.
--instance-selection=name=NAME,machine-type=MACHINE_TYPE[,machine-type=MACHINE_TYPE…][,rank=RANK]- Named selection of machine types with an optional rank. For example,
--instance-selection="name=instance-selection-1,machine-type=e2-standard-8,machine-type=t2d-standard-8,rank=0" --instance-selection-machine-types=[MACHINE_TYPE,…]- Machine types that are used to create VMs in the managed instance group. If notprovided, the machine type specified in the instance template is used.
--list-managed-instances-results=MODE- Pagination behavior for the group's listManagedInstances API method. This flagdoes not affect the group's gcloud or console list-instances behavior. Bydefault it is set to
.pagelessMODEmust be one of:pageless- Pagination is disabled for the group's listManagedInstances API method.maxResults and pageToken query parameters are ignored and all instances arereturned in a single response.
paginated- Pagination is enabled for the group's listManagedInstances API method.maxResults and pageToken query parameters are respected.
--on-repair-allow-changing-zone=ON_REPAIR_ALLOW_CHANGING_ZONE- Specifies whether the MIG can change a VM's zone during a repair.
ON_REPAIR_ALLOW_CHANGING_ZONEmust be one of:no- (Default) MIG cannot change a VM's zone during a repair.
yes- MIG can select a different zone for the VM during a repair.
--resource-manager-tags=[KEY=VALUE,…]- Specifies a list of resource manager tags to apply to the managed instancegroup. A resource manager tag is a key-value pair. You can attach exactly onevalue to a MIG for a given key. A MIG can have a maximum of 50 key-value pairsattached.
--standby-policy-initial-delay=STANDBY_POLICY_INITIAL_DELAY- Specifies the number of seconds that the MIG should wait before suspending orstopping a VM. The initial delay gives the initialization script the time toprepare your VM for a quick scale out.
--standby-policy-mode=STANDBY_POLICY_MODE- Defines how a MIG resumes or starts VMs from a standby pool when the groupscales out. The default mode is
.manualSTANDBY_POLICY_MODEmust be one of:manual- MIG does not automatically resume or start VMs in the standby pool when thegroup scales out.
scale-out-pool- MIG automatically resumes or starts VMs in the standby pool when the groupscales out, and replenishes the standby pool afterwards.
--stateful-disk=[auto-delete=AUTO-DELETE],[device-name=DEVICE-NAME]- Disks considered stateful by the instance group. Managed instance groupspreserve and reattach stateful disks on VM autohealing, update, and recreateevents.
Use this argument multiple times to attach more disks.
device-name- (Required) Device name of the disk to mark stateful.
auto-delete- (Optional) Specifies the auto deletion policy of the stateful disk. Thefollowing options are available:
: (Default) Never delete this disk.Instead, detach the disk when its instance is deleted.never: Delete thestateful disk when the instance that it's attached to is permanently deletedfrom the group; for example, when the instance is deleted manually or when thegroup size is decreased.on-permanent-instance-deletion
--stateful-external-ip=[enabled],[auto-delete=AUTO-DELETE],[interface-name=INTERFACE-NAME]- External IPs considered stateful by the instance group. Managed instance groupspreserve stateful IPs on VM autohealing, update, and recreate events.
Use this argument multiple times to make more external IPs stateful.
At least one of the following is required:
enabled- Marks the IP address as stateful. The network interface named
is assumed by default whennic0is not specified. This flagcan be omitted wheninterface-nameisprovided explicitly.interface-name interface-name- Marks the IP address from this network interface as stateful. This flag can beomitted when
is provided.Additional arguments:enabled auto-delete- (Optional) Prescribes what should happen to an associated static Addressresource when a VM instance is permanently deleted. Regardless of the value ofthe delete rule, stateful IP addresses are always preserved on instanceautohealing, update, and recreation operations. The following options areavailable:
: (Default) Never delete the static IPaddress. Instead, unassign the address when its instance is permanently deletedand keep the address reserved.never: Delete thestatic IP address reservation when the instance that it's assigned to ispermanently deleted from the instance group; for example, when the instance isdeleted manually or when the group size is decreased.on-permanent-instance-deletion
--stateful-internal-ip=[enabled],[auto-delete=AUTO-DELETE],[interface-name=INTERFACE-NAME]- Internal IPs considered stateful by the instance group. Managed instance groupspreserve stateful IPs on VM autohealing, update, and recreate events.
Use this argument multiple times to make more internal IPs stateful.
At least one of the following is required:
enabled- Marks the IP address as stateful. The network interface named
is assumed by default whennic0is not specified. This flagcan be omitted wheninterface-nameisprovided explicitly.interface-name interface-name- Marks the IP address from this network interface as stateful. This flag can beomitted when
is provided.Additional arguments:enabled auto-delete- (Optional) Prescribes what should happen to an associated static Addressresource when a VM instance is permanently deleted. Regardless of the value ofthe delete rule, stateful IP addresses are always preserved on instanceautohealing, update, and recreation operations. The following options areavailable:
: (Default) Never delete the static IPaddress. Instead, unassign the address when its instance is permanently deletedand keep the address reserved.never: Delete thestatic IP address reservation when the instance that it's assigned to ispermanently deleted from the instance group; for example, when the instance isdeleted manually or when the group size is decreased.on-permanent-instance-deletion
--stopped-size=STOPPED_SIZE- Specifies the target size of stopped VMs in the group.
--suspended-size=SUSPENDED_SIZE- Specifies the target size of suspended VMs in the group.
--target-distribution-shape=SHAPE- Specifies how a regional managed instance group distributes its instances acrosszones within the region. The default shape is
.evenSHAPEmust beone of:any- The group picks zones for creating VM instances to fulfill the requested numberof VMs within present resource constraints and to maximize utilization of unusedzonal reservations. Recommended for batch workloads that do not require highavailability.
any-single-zone- The group schedules all instances within a single zone. The zone is chosen basedon hardware support, current resources availability, and matching reservations.The group might not be able to create the requested number of VMs in case ofzonal resource availability constraints. Recommended for workloads requiringextensive communication between VMs.
balanced- The group prioritizes acquisition of resources, scheduling VMs in zones whereresources are available while distributing VMs as evenly as possible acrossselected zones to minimize the impact of zonal failure. Recommended for highlyavailable serving or batch workloads that do not require autoscaling.
even- The group schedules VM instance creation and deletion to achieve and maintain aneven number of managed instances across the selected zones. The distribution iseven when the number of managed instances does not differ by more than 1 betweenany two zones. Recommended for highly available serving workloads.
--target-pool=[TARGET_POOL,…]- Specifies any target pools you want the instances of this managed instance groupto be part of.
--target-size-policy-mode=TARGET_SIZE_POLICY_MODE- Specifies the mode in which the MIG creates VMs in the group.
TARGET_SIZE_POLICY_MODEmust be one of:bulk- MIG creates VMs all at once. If the MIG cannot create any VM to meet thespecified ``size``, then the MIG waits until the resources become available tocreate all VMs.
individual- (Default) MIG creates VMs individually. If the MIG cannot create any VM to meetthe specified ``size``, then the MIG creates the VMs for which resources areavailable. The MIG then attempts to create the remaining VMs until the resourcesbecome available.
--workload-policy=WORKLOAD_POLICY- Specifies the workload policy for the managed instance group. It can be a fullor partial URL to a resource policy containing the workload policy.
--zones=ZONE,[ZONE,…]- If this flag is specified a regional managed instance group will be created. Themanaged instance group will be in the same region as specified zones and willspread instances in it between specified zones.
All zones must belong to the same region. You may specify --region flag but itmust be the region to which zones belong. This flag is mutually exclusive with--zone flag.
- At most one of these can be specified:
--health-check=HEALTH_CHECK- Name of the health check to operate on.
--http-health-check=HTTP_HEALTH_CHECK- (DEPRECATED) HTTP health check object used for autohealing instances in thisgroup.
HttpHealthCheck is deprecated. Use --health-check instead.
--https-health-check=HTTPS_HEALTH_CHECK- (DEPRECATED) HTTPS health check object used for autohealing instances in thisgroup.
HttpsHealthCheck is deprecated. Use --health-check instead.
- At most one of these can be specified:
--region=REGION- Region of the managed instance group to create. If not specified, you might beprompted to select a region (interactive mode only).
A list of regions can be fetched by running:
If you specifygcloudcomputeregionslist--zonesflag this flag must be unspecified orspecify the region to which the zones you listed belong.Overrides the default
compute/regionproperty value for thiscommand invocation. --zone=ZONE- Zone of the managed instance group to create. If not specified, you might beprompted to select a zone (interactive mode only).
A list of zones can be fetched by running:
gcloudcomputezoneslistOverrides the default
compute/zoneproperty value for this commandinvocation.
- Parameters for setting update policy for this managed instance group.
--update-policy-max-surge=MAX_SURGE- Maximum additional number of VMs that can be created during the update process.This can be a fixed number (e.g. 5) or a percentage of size to the managedinstance group (e.g. 10%).
--update-policy-max-unavailable=MAX_UNAVAILABLE- Maximum number of VMs that can be unavailable during the update process. Thiscan be a fixed number (e.g. 5) or a percentage of size to the managed instancegroup (e.g. 10%). Defaults to the number of zones in which the managed instancegroup operates.
--update-policy-min-ready=MIN_READY- Minimum time for which a newly created VM should be ready to be consideredavailable. For example
10sfor 10 seconds. See $gcloud topic datetimes forinformation on duration formats. --update-policy-minimal-action=UPDATE_POLICY_MINIMAL_ACTION- Use this flag to minimize disruption as much as possible or to apply a moredisruptive action than is strictly necessary. The MIG performs at least thisaction on each VM while updating. If the update requires a more disruptiveaction than the one specified here, then the more disruptive action isperformed.
UPDATE_POLICY_MINIMAL_ACTIONmust be one of:none- No action
refresh- Apply the new configuration without stopping VMs, if possible. For example, use``refresh`` to apply changes that only affect metadata or additional disks.
restart- Apply the new configuration without replacing VMs, if possible. For example,stopping VMs and starting them again is sufficient to apply changes to machinetype.
replace- Replace old VMs according to the --update-policy-replacement-method flag.
--update-policy-most-disruptive-action=UPDATE_POLICY_MOST_DISRUPTIVE_ACTION- Use this flag to prevent an update if it requires more disruption than you canafford. At most, the MIG performs the specified action on each VM whileupdating. If the update requires a more disruptive action than the one specifiedhere, then the update fails and no changes are made.
UPDATE_POLICY_MOST_DISRUPTIVE_ACTIONmust be one of:none- No action
refresh- Apply the new configuration without stopping VMs, if possible. For example, use``refresh`` to apply changes that only affect metadata or additional disks.
restart- Apply the new configuration without replacing VMs, if possible. For example,stopping VMs and starting them again is sufficient to apply changes to machinetype.
replace- Replace old VMs according to the --update-policy-replacement-method flag.
--update-policy-replacement-method=UPDATE_POLICY_REPLACEMENT_METHOD- Type of replacement method. Specifies what action will be taken to update VMs.
UPDATE_POLICY_REPLACEMENT_METHODmust be one of:recreate- Recreate VMs and preserve the VM names. The VM IDs and creation timestamps mightchange.
substitute- Delete old VMs and create VMs with new names.
--update-policy-type=UPDATE_TYPE- Specifies the type of update process. You can specify either ``proactive`` sothat the managed instance group proactively executes actions in order to bringVMs to their target versions or ``opportunistic`` so that no action isproactively executed but the update will be performed as part of other actions.
UPDATE_TYPEmust be one of:opportunistic- Do not proactively replace VMs. Create new VMs and delete old ones on resizes ofthe group and when you target specific VMs to be updated or recreated.
proactive- Replace VMs proactively.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudcomputeinstance-groupsmanagedcreategcloudbetacomputeinstance-groupsmanagedcreate
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-10-21 UTC.