Search code examples
google-cloud-platformautomationgoogle-compute-engineclonegcloud

Clone an instance in GCP


I need a Compute Engine instance to import the exact configuration (IP, services, files, etc...) of the original machine, without impacting the frontend if it concerns a web server for example. While running this machine, I would be able to shut down the original machine to increase its RAM or vCPUs before starting it again and deleting the cloned instance.

The problem is that I want to automate this process, and that's why I need the gcloud command. So is there a way to clone an entire gcp instance using the gcloud command or another tool?


Solution

  • This is not possible with the gcloud. This is possible with the cloud console, but as you can see in this documentation:

    Restrictions

    You can only use this feature in the Cloud Console; this feature is not supported in the gcloud tool or the API.

    What you could do is create similar (not completely equal) instances from a custom image, using that all you have to do is use the following command:

    gcloud compute instances create --image=IMAGE
    

    More details on that command can be found here