Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy one app engine app to multiple projects

My problem is that I want to create dev, stage, prod environments by using different GCP projects.

Basically they are running the same code, just running them in different isolated environments.

I'm using gcloud app deploy in command line to deploy app right now.

How can I efficiently deploy an app to different project?
Do I have to do gcloud init to change my configuration of default project every time?
There must be some better practices.

Or, is there a better way for me to set up dev... environments in the context of app engine?

Thanks.

like image 303
Lucas Shen Avatar asked Dec 25 '22 01:12

Lucas Shen


1 Answers

Instead of using gcloud init to change your configuration each time, use this code to deploy to multiple projects faster:

gcloud app deploy -q --project [YOUR_PROJECT_ID]

If your projects have similar IDs, let's say: test1, test2, test3, test4, You can deploy to the four projects with one command. Use this code:

for i in {1..4}; do gcloud app deploy -q --project test${i}; done
like image 60
Ibrahim Avatar answered Jan 19 '23 01:01

Ibrahim