How do I get the organization ID of my current project in Google Cloud Platform?
Jan 15
I would like to know the organization ID of my current project in GCP.
gcloud projects describe PROJECT_ID will show the parent which can be the organization, but if the parent is a folder, the organization ID does not appear.
I could recurse up the parent hierarchy of the folders using gcloud resource-manager folders describe FOLDER_ID, but that is a hassle. It is also impossible if I do not have organization-level permissions.
Yet I do have access to organization IDs: gcloud organizations list shows several organizations, though not their mapping to projects.
How can I achieve this?
1 answer
Accepted answer · original discussion
Jun 20
Use the below gcloud command in cloud shell.
gcloud projects get-ancestors {projectId}
This should give the output as below.
ID TYPE
Your-project-ID project
123456789012 folder
567890123456 organization
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
Jan 15