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 ?
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