Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil: specify project on copy

Tags:

gsutil

I'm attempting to come up with commands to facilitate deployment to different environments (production, staging) in my GCP project using gsutil.

The following deploys to production without issue:

gsutil cp -r ./build/* gs://<production-project-name>/

I'd like to deploy to a bucket in another project. The gsutil help page alludes to a -p option for ls and mb used to change the project context of the gsutil command.

I'd like to use a command like this to deploy my app to a staging environment:

gsutil cp -r ./build/* gs://<existing-bucket-in-staging-project>/ -p <staging-project-name>

Alas, the -p option is not available for the cp command. I confirmed on the gsutil cp doc page.

What is the best way to deploy a build artifact to a Google Cloud storage bucket to a bucket in a project other than the one currently specified in the terminal environment?

like image 285
Tarik Avatar asked Oct 19 '25 21:10

Tarik


1 Answers

The bucket namespace is global, so as long as the credentials you're using have permission to the other project, you shouldn't need a project parameter with the cp command. In other words, this command should work fine:

gsutil cp -r ./build/* gs://<bucket-in-staging-project>
like image 176
Travis Hobrla Avatar answered Oct 22 '25 04:10

Travis Hobrla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!