Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to clone a cloud project

I need to clone an existing project with all databases, data storage and cloud functions in it. Is that even possible?

Thanks

0 13 7,458
13 REPLIES 13

Hi @arunahk , I'm not aware of a way to "clone" a project. But you could consider generating a Terraform configuration of your existing project (using Terraformer) and then using that configuration to deploy resources to a new project. Note that Terraformer is not an official Google tool.

Terraformer certainly looks interesting, I'll be trying it out.

Some GCP resources need to be globally unique (e.g. Buckets, Cloud SQL) so you may get errors when deploying your copy to a new project. To workaround you'll need to rename these but also check Cloud Functions code doesn't point to the original locations (especially if it's a Production system 😊).

I agree, @PetePlatt .  The config that Terraformer generates can't/shouldn't be used as is to provision the new environment.

do you know how to generate terraform for an existing project on live?

I wouldn't trust any automated tool to generate terraform code for a live system. The number of ways components can be configured to interact with each other (e.g. config file, database entry, project metadata, KMS) is too huge to expect a generic tool to know how to find and understand all of them.

I've always created terraform code manually for existing projects, then used the terraform import function to load into the state file when needed. This doesn't include any data because terraform is mainly for Infrastructure as Code, not Data as Code.

 

To answer your original question, creating an exact clone isn't possible because Buckets, Cloud Functions & Cloud SQL instances (among others) must be globally unique. For that reason you can't create a "backup" project to use as disaster recovery if your main project goes down.

You should be able to create a "template" for a live project assuming all the following are true:

  • the data isn't restricted for use outside production, e.g. financial data
  • the design is well understood and/or well documented
  • the deployment and configuration process is also well understood and/or well documented

For a simple project with good documentation I'd expect at least a month to create a fully tested automated deployment assuming all the above points are true. If it isn't well documented then you need to add the time it takes to reverse-engineer the project, which is impossible to predict.

Hey Pete - I had a similar question regarding cloning a Project - in my situation, the user that originally created the project exited the org., and unfortunately, was the only owner/admin and all other users only have edit access, but unable to make certain changes.  The reason we were asking if there's a way to clone is to take the existing project, into a new Project and making changes and be able to add multiple owners, so they don't run into that issue again.

Any recommendations for this scenario?  Appreciate your response.

If your organisation has lost control of a GCP project it's paying for then I would prioritise regaining access to it.

Trying to clone it may not be possible for a number of reasons, and would still leave the original running up costs even if you were lucky enough to achieve this.

Reaching out to Google though the Help -> Get support  option in the cloud console would be my next step.

I think i saw this question in Stackoverflow, i asked the follow up there but didn't get an answer.

Do you still have the user in workspace ? If yes you could reset their password and log-in as them 

If your org has Workspace then an administrator should be able to assign permissions to an appropriate user (or better still, group of users) to gain more access to the project. I assumed (perhaps wrongly) that you weren't a Workspace customer.

Unfortunately, I don't have user in the Workspace - our users data is transfer and the account deleted once they exit the org.

Hi All,

Really appreciate your responses and I did a double take on the permissions peace for the super admin of the Google Workspace.  I thought I was the administrator Org for the GCP - I proceeded to add myself at the Org level and the Organization administrator and now I can see the Project and change the user from editor to owner.  

This resolved my issue - many thx.

It's not possible to clone a GCP project. I read the thread and the Terraform solution will not work. Terraform could potentially make it easier to re-create the resources in the new project but will not move your data (buckets, databases, persistent disk...) Will still need to be transferred manually.

Making a copy of the complete infrastructure is at least a good step on the way, it would take me at least a few workdays just to re-create all the resources manually.

Top Solution Authors