How to get the GCP PROJECT_NUMBER from the PROJECT_ID or get the PROJECT_ID from the PROJECT_NUMBER with gcloud CLI?

521 Views Asked by At

Is there a way via gcloud to find project_id from project_number, or project_number from project_id without knowing one of the two?

1

There are 1 best solutions below

1
Riccardo On

I was able to craft the perfect gcloud command which does NOT require the project to be the current project:

  1. Get project id from project number 1234567890:

gcloud projects list --filter PROJECT_NUMBER=1234567890 --format="value(PROJECT_ID)"

  1. Get project number from project id pincopallo:

gcloud projects list --filter PROJECT_ID=pincopallo --format="value(PROJECT_NUMBER)"