Stay organized with collections Save and categorize content based on your preferences.
This document describes how to create a managed instance group (MIG) in a single zone. Putting all your MIG's VMs in a single zone helps to minimize latency, which is useful for certain workloads—for example, batch workloads.
This type of MIG is also known as a zonal MIG.
You can also read about other basic scenarios for creating a MIG.
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
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
.To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
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
.
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
RESTTo 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.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
To see the full list of MIG limitations, which varies based on the configuration that you use, see MIG limitations.
Create a MIG in a single zoneTo create a MIG in a single zone, use the Google Cloud console, the gcloud CLI, Terraform, or REST.
Permissions required for this taskTo perform this task, you must have the following permissions:
instanceGroupManagers.insert
method.In the Google Cloud console, go to the Instance groups page.
The remaining steps appear in the Google Cloud console.
If you haven't already created an instance template, which specifies the machine type, boot disk image, network, and other VM properties that you want for each VM in your MIG, create an instance template.
Create a managed instance group with the instance-groups managed create
command and specify the group name, group size, instance template, and zone.
gcloud compute instance-groups managed create INSTANCE_GROUP_NAME \ --size SIZE \ --template INSTANCE_TEMPLATE_URL \ --zone ZONE
Replace the following:
INSTANCE_GROUP_NAME
: the name for this instance group.SIZE
: the size of the instance group.INSTANCE_TEMPLATE_URL
: the URL of the instance template that you want to use to create VMs in the MIG. The URL can contain either the ID or name of the instance template. Specify one of the following values:
projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_ID
INSTANCE_TEMPLATE_ID
ZONE
: one of the zones available for Compute Engine. If you want to distribute your MIG's VMs across multiple zones in a region, see Create a regional MIG.You can optionally supply the --base-instance-name
flag. Because these VMs are based on a common template, each VM is assigned a random string as part of its VM name. The base name is prepended to this random string. For example, if you set the base name to test
, VMs will have names like test-yahs
and test-qtyz
. If you need specific names, see Creating instances with specific names in MIGs.
For example, the following command creates an instance group named example-group, with base VM name test
. The group contains three instances:
gcloud compute instance-groups managed create example-group \ --base-instance-name test \ --size 3 \ --template an-instance-template \ --zone us-central1-fTerraform
If you haven't already created an instance template, which specifies the machine type, boot disk image, network, and other VM properties that you want for each VM in your MIG, create an instance template.
To create a zonal MIG, you can use the google_compute_instance_group_manager
resource.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
RESTIf you haven't already created an instance template, which specifies the machine type, boot disk image, network, and other VM properties that you want for each VM in your MIG, create an instance template.
Create a managed instance group with the instanceGroupManagers.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
: the zone for the request. If you want to distribute your MIG's VMs across multiple zones in a region, replace zones/ZONE
with regions/REGION
and specify a region. For more information, see Create a regional MIG.INSTANCE_GROUP_NAME
: the name for this instance group.SIZE
: the size of the instance group.INSTANCE_TEMPLATE_URL
: the URL of the instance template that you want to use to create VMs in the MIG. The URL can contain either the ID or name of the instance template. Specify one of the following values:
projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_ID
INSTANCE_TEMPLATE_ID
You can optionally supply the base-name
field. Because these VMs are based on a common template, each VM is assigned a random string as part of its VM name. The base name is prepended to this random string. For example, if you set the base name to test
, VMs will have names like test-yahs
and test-qtyz
. If you need specific names, see Creating instances with specific names in MIGs.
Depending on how you configure and act on a MIG, various policies and actions can affect the instances in the group. To determine which managed instances are up and running, see Checking the status of managed instances.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document guides users on creating a managed instance group (MIG) within a single zone, also known as a zonal MIG, which minimizes latency for workloads like batch processing."],["Before creating a MIG, you must first create an instance template that defines the properties of the VMs within the group."],["You can create a single-zone MIG using the Google Cloud console, gcloud CLI, Terraform, or REST API, each method requiring specific configurations and steps."],["Managed instance groups support features like autoscaling, autohealing, and stateful configurations to manage the VMs within the group effectively."],["After setting up the MIG, there are several next steps, such as setting up autohealing, enabling autoscaling, applying new configurations, and configuring stateful MIGs."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4