I have Google Cloud Service account and projectId and want to get projectNumber programmatically from Java.
How can I get it?
Basically I have Service Account and want to use it for granting role "roles/storage.legacyBucketWriter" for the account "[email protected]" in the Google Cloud Storage Bucket.
The project ID is a unique identifier for a project and is used only within the console. When you first create a project, you can accept the default generated project ID or create your own.
To see all your gcloud projects you use command gcloud projects list . To switch to a specific project, you use gcloud config set project PROJECT_ID .
To confirm who owns the project, go to the Google Cloud Platform Console, open the console left side menu, and click IAM & Admin. Ensure that a project is selected to see the project owner.
Not sure why they don't expose it directly, but you can do this (assuming your current configuration project corresponds to the desired project number):
gcloud projects list \
--filter="$(gcloud config get-value project)" \
--format="value(PROJECT_NUMBER)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With