Create a MIG with stateful disks
Stay organized with collections
Save and categorize content based on your preferences.
This document describes how to create a
managed instance group (MIG)
that preserves the data on disks with a given device name for all of the MIG's
VMs, even in the event of VM recreation—for example when a VM in the MIG is
autohealed, updated, or recreated. Preserving disks is useful for certain
workloads—for example, for databases or legacy applications.
In addition to preserving disks for all VMs in the group, you can also configure
a stateful MIG for the following:
You can add and preserve instance-specific disks.
You can add and preserve instance-specific metadata.
If you haven't already, set up authentication.
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:
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.
You cannot use autoscaling if your MIG has stateful configuration.
If you want to use automated rolling updates, you must set the
replacement method
to RECREATE.
For stateful regional MIGs, you must
disable proactive redistribution
(set the redistribution type to NONE) to prevent deletion of stateful
instances by automatic cross-zone redistribution.
If you use an all-instances configuration
to override instance template properties, you cannot specify those properties
in any per-instance configuration and at the same time in the group's
all-instances configuration.
To see the full list of MIG limitations, which varies based on the configuration
that you use, see
MIG limitations.
Compute Engine doesn't automatically delete stateful persistent disks that you
detach from the MIG. You are still billed for the provisioned space of any
detached persistent disks. To avoid incurring disk space costs after a disk is
detached, delete the disk. For more information, see
Disk pricing.
What's next
Learn more about stateful MIGs
and when to use them.
[[["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 2026-06-09 UTC."],[],[]]