How to figure out what Google Cloud project a Cloud Storage bucket is in

Leah Cole
2 min readApr 26, 2023

Earlier today a friend said to me, “How do I know what Google Cloud project a Cloud Storage (GCS) bucket is in? I want to be able to look at it in the Cloud Console!” This was a fair question, because there are cases where it may not be immediately obvious!

Let’s say you have been given the ID of a GCS bucket: LeahsAmazingBucket (I am using a fake and invalid bucket name here so if you try these operations with this bucket name they will fail.)

What can you do without the project info?

Given only the bucket ID, assuming you are logged into the Cloud Console and you have permissions that allow you to access this bucket, you can browse the bucket contents by going straight to its Cloud Console URL: https://console.cloud.google.com/storage/browser/LeahsAmazingBucket. If you look closely in the upper left hand corner, you will see the words “Select a Project” instead of the project name, but you will still be able to see your bucket details.

screenshot of the cloud console with the “Select a project” dropdown visible

You can also run certain gcloud and gsutil commands without knowing the project name. For example, you can run gsutil ls gs://LeahsAmazingBucket to see the bucket contents.

How to get the project info for your bucket?

If just being able to access the bucket without knowing the project info is enough, then great! But, if you still need this info, you can do the following:

  1. In Cloud Shell or in a terminal where you are authenticated to gcloud, run gcloud storage buckets describe gs://LeahsAmazingBucket This will return information about your bucket including the projectNumber in string format. In this example, the project number is 0123456789
etag: CAo=
iamConfiguration:
bucketPolicyOnly:
enabled: true
lockedTime: '2021-08-02T18:39:08.407000+00:00'
publicAccessPrevention: inherited
uniformBucketLevelAccess:
enabled: true
lockedTime: '2021-08-02T18:39:08.407000+00:00'
id: LeahsAmazingBucket
kind: storage#bucket
location: US
locationType: multi-region
metageneration: '10'
name: LeahsAmazingBucket
projectNumber: '0123456789'
rpo: DEFAULT
selfLink: https://www.googleapis.com/storage/v1/b/LeahsAmazingBucket
storageClass: STANDARD
timeCreated: '2021-05-04T18:39:08.407000+00:00'
updated: '2021-09-01T18:17:27.317000+00:00'

2. Run gcloud projects describe <yourProjectNumber> with the project number from step 1. For example, gcloud projects describe 0123456789. This will return a config object that has the name and project ID of your project!

createTime: '2018-11-27T19:38:55.858Z'
lifecycleState: ACTIVE
name: LeahsAmazingProject
parent:
id: '987654321'
type: folder
projectId: LeahsAmazingProject
projectNumber: '0123456789'

--

--

Leah Cole

DPE @GCPcloud. @GEDTLP alum, Boston sports fan. Previously @GE_Digital, @MITLL, @CarletonCollege. Currently unapologetically awesome. she/her