Reputation: 560
I have created one gcp instance in default vpc. But now i knew that VM needed to created in another vpc.
So far, i have done lot of work on it. So creating new vm in other vpc and do same stuff there is not possible.
I have read somewhere that VPC can be selected only while creating instance. Can i change the VPC and Subnet of my instance ?
Upvotes: 0
Views: 5226
Reputation: 382
The simple answer is YES. But you should stop the instance before moving to the other VPC otherwise you will not allowed to do so. You can change the VPC simply by using the console under advance->networking
.
Upvotes: 0
Reputation: 2448
Can I change the VPC and Subnet of my instance ? The short answer is Yes, you can.
If you already have your new VPC create you can follow the steps below if not you can consult the following documentation: Creating networks
To migrate a VM instance from one network to another.
Also you can execute this change by gcloud command line:
gcloud beta compute instances stop INSTANCE_NAME \
--zone=ZONE_NAME
gcloud beta compute instances network-interfaces update INSTANCE_NAME \
--zone=ZONE_NAME \
--network-interface=NIC \
--network=NETWORK_NAME \
--subnetwork=SUBNET_NAME
3.Start the VM
gcloud beta compute instances start INSTANCE_NAME \
--zone=ZONE_NAME
Please check the following documentation for further details
Upvotes: 2