GCP Move VM to another VPC
Here’s how to move a VM to another VPC.
Stop VM.
<pre lang="bash">
gcloud compute instances stop $INSTANCE_NAME \
--zone $ZONE_NAME \
--project $PROJECT_ID
Move VM to another VPC.
<pre lang="bash">
gcloud compute instances network-interfaces update $INSTANCE_NAME \
--zone $ZONE_NAME \
--network-interface=nic0 \
--network $YOUR_NETWORK \
--subnetwork $YOUR_SUBNETWORK \
--project $PROJECT_ID
Start VM.
<pre lang="bash">
gcloud compute instances start $INSTANCE_NAME \
--zone $ZONE_NAME \
--project $PROJECT_ID