This document explains how to suspend and stop virtual machine (VM) instances in a managed instance group (MIG), and how to resume their operation.
Before you begin
- Review the introductory page about suspended and stopped VMs in a MIG.
-
If you haven't already, set up authentication.
Authentication verifies your identity for access to Cloud de Confiance by S3NS 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 Cloud de Confiance console to access Cloud de Confiance by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, and then sign in to the gcloud CLI with your federated identity. After signing in, initialize the Google Cloud CLI by running the following command:
gcloud init - 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, and then sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Cloud de Confiance authentication documentation.
-
Suspend specific VMs in a MIG
You can suspend a running VM in a MIG using the Cloud de Confiance console, the Google Cloud CLI, or the Compute Engine API.
Console
- In the Cloud de Confiance console, go to the Instance groups page.
- Click the instance group name where you want to suspend VMs.
- In the instance group Overview page, under VM instances, select all the VMs that you want to suspend.
- Click Suspend.
- In the confirmation dialog that appears, click Suspend to confirm.
gcloud
Use the
instance-groups managed suspend-instances command.
gcloud compute instance-groups managed suspend-instances MIG_NAME \ --instances=INSTANCE_NAME \ [--region=REGION | --zone=ZONE]
Replace the following:
MIG_NAME: the name of the MIG in which to suspend an instance.INSTANCE_NAME: the name of the instance to suspend. To suspend multiple instances, provide a comma-separated list of names.REGION: for a regional MIG, the region where the MIG is located.ZONE: for a zonal MIG, the zone where the MIG is located.
REST
Use the
instanceGroupManager.suspendInstances method
and specify the instances in the request body.
For regional MIGs, use the
regionInstanceGroupManager.suspendInstances method.
POST https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/MIG_NAME/suspendInstances
{
"instances": [
"INSTANCE_NAME_URL"
]
}
Replace the following:
PROJECT_ID: the project ID for the request.ZONE: for a zonal MIG, the zone where the MIG is located.- For a regional MIG, replace
zones/ZONEwithregions/REGIONand specify the region of the MIG.
- For a regional MIG, replace
MIG_NAME: the name of the MIG in which to suspend an instance.INSTANCE_NAME_URL: the URL of the instance to suspend—for example,zones/us-central1-a/instances/example-instance-name1. To suspend multiple instances, provide a comma-separated list of URLs—for example,"zones/us-central1-a/instances/example-instance-name1","zones/us-central1-a/instances/example-instance-name2".
Resume selected VMs in a MIG
You can resume a suspended VM in a MIG using the Cloud de Confiance console, the gcloud CLI, or the Compute Engine API.
Console
- In the Cloud de Confiance console, go to the Instance groups page.
- Click the instance group name where you want to resume VMs.
- In the instance group Overview page, under VM instances, select all the suspended VMs that you want to resume, then click Start/Resume.
gcloud
Use the
instance-groups managed resume-instances command.
gcloud compute instance-groups managed resume-instances MIG_NAME \ --instances=INSTANCE_NAME \ [--region=REGION | --zone=ZONE]
Replace the following:
MIG_NAME: the name of the MIG in which to resume an instance.INSTANCE_NAME: the name of the instance to resume. To resume multiple instances, provide a comma-separated list of names.REGION: for a regional MIG, the region where the MIG is located.ZONE: for a zonal MIG, the zone where the MIG is located.
REST
Use the
instanceGroupManager.resumeInstances method
and specify the instances in the request body.
For regional MIGs, use the
regionInstanceGroupManager.resumeInstances method.
POST https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/MIG_NAME/resumeInstances
{
"instances": [
"INSTANCE_NAME_URL"
]
}
Replace the following:
PROJECT_ID: the project ID for the request.ZONE: for a zonal MIG, the zone where the MIG is located.- For a regional MIG, replace
zones/ZONEwithregions/REGIONand specify the region of the MIG.
- For a regional MIG, replace
MIG_NAME: the name of the MIG in which to resume an instance.INSTANCE_NAME_URL: the URL of the instance to resume—for example,zones/us-central1-a/instances/example-instance-name1. To resume multiple instances, provide a comma-separated list of URLs—for example,"zones/us-central1-a/instances/example-instance-name1","zones/us-central1-a/instances/example-instance-name2".
Stop selected VMs in a MIG
If you've enabled graceful shutdown in the instance template that your MIG uses, then the running VMs in your MIG gracefully shut down when you stop them. When you stop a running VM, you can optionally skip a graceful shutdown, or end an ongoing graceful shutdown when all tasks have finished running, to reduce unnecessary costs.
You can stop a running VM in a MIG by using the Cloud de Confiance console, the Google Cloud CLI, or the Compute Engine API.
Console
In the Cloud de Confiance console, go to the Instance groups page.
Click the name of the MIG where you want to stop VMs. The Overview page appears.
In the VM instances list, select all the VMs that you want to stop, then click Stop. If there is no Stop option, then click More actions, and then select Stop.
In the dialog that appears, do the following:
Optional: To stop VMs without using graceful shutdown, or to end an ongoing graceful shutdown, select the Skip graceful shutdown (if applicable) checkbox.
To confirm, click Stop.
gcloud
Use the
instance-groups managed stop-instances command.
gcloud compute instance-groups managed stop-instances MIG_NAME \
--instances=INSTANCE_NAME \
[--region=REGION | --zone=ZONE]
Replace the following:
MIG_NAME: the name of the MIG in which to stop an instance.INSTANCE_NAME: the name of the instance to stop. To stop multiple instances, provide a comma-separated list of names.REGION: for a regional MIG, the region where the MIG is located.ZONE: for a zonal MIG, the zone where the MIG is located.
If you want to skip or end a graceful shutdown, then use the same command
with the --no-graceful-shutdown flag:
gcloud compute instance-groups managed stop-instances MIG_NAME \
--instances=INSTANCE_NAME \
--no-graceful-shutdown \
[--region=REGION | --zone=ZONE]
REST
Use the
instanceGroupManager.stopInstances method
and specify the instances in the request body. For regional MIGs, use the
regionInstanceGroupManager.stopInstances method.
POST https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/MIG_NAME/stopInstances
{
"instances": [
"INSTANCE_NAME_URL"
]
}
Replace the following:
PROJECT_ID: the project ID for the request.ZONE: for a zonal MIG, the zone where the MIG is located.- For a regional MIG, replace
zones/ZONEwithregions/REGIONand specify the region of the MIG.
- For a regional MIG, replace
MIG_NAME: the name of the MIG in which to stop an instance.INSTANCE_NAME_URL: the URL of the instance to stop—for example,zones/us-central1-a/instances/example-instance-name1. To stop multiple instances, provide a comma-separated list of URLs—for example,"zones/us-central1-a/instances/example-instance-name1","zones/us-central1-a/instances/example-instance-name2".
If you want to skip or end a graceful shutdown, then include the
noGracefulShutdown query parameter set to true in the request URL:
POST https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/MIG_NAME/stopInstances?noGracefulShutdown=true
{
"instances": [
"INSTANCE_NAME_URL"
]
}
Start selected VMs in a MIG
You can start a stopped VM in a MIG using the Cloud de Confiance console, the gcloud CLI, or the Compute Engine API.
Console
- In the Cloud de Confiance console, go to the Instance groups page.
- Click the instance group name where you want to start VMs.
- In the instance group Overview page, under VM instances, select all the stopped VMs that you want to start, then click Start/Resume.
gcloud
Use the
instance-groups managed start-instances command.
gcloud compute instance-groups managed start-instances MIG_NAME \ --instances=INSTANCE_NAME \ [--region=REGION | --zone=ZONE]
Replace the following:
MIG_NAME: the name of the MIG in which to start an instance.INSTANCE_NAME: the name of the instance to start. To start multiple instances, provide a comma-separated list of names.REGION: for a regional MIG, the region where the MIG is located.ZONE: for a zonal MIG, the zone where the MIG is located.
REST
Use the
instanceGroupManager.startInstances method
and specify the instances in the request body.
For regional MIGs, use the
regionInstanceGroupManager.startInstances method.
POST https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/MIG_NAME/startInstances
{
"instances": [
"INSTANCE_NAME_URL"
]
}
Replace the following:
PROJECT_ID: the project ID for the request.ZONE: for a zonal MIG, the zone where the MIG is located.- For a regional MIG, replace
zones/ZONEwithregions/REGIONand specify the region of the MIG.
- For a regional MIG, replace
MIG_NAME: the name of the MIG in which to start an instance.INSTANCE_NAME_URL: the URL of the instance to start—for example,zones/us-central1-a/instances/example-instance-name1. To start multiple instances, provide a comma-separated list of URLs—for example,"zones/us-central1-a/instances/example-instance-name1","zones/us-central1-a/instances/example-instance-name2".
What's next
- Learn how to accelerate scale out with the standby pool.