Skip to main content
  1. Posts/

GCP - How do I get a list of all Projects in an Organization ?

1 min· loading · ·
Author
David Haines
Topically ephemeral IT Insights
Table of Contents

GCP (Google Cloud): Getting a list of all Projects in a GCP Org (tenant)
#

When dealing with Google Cloud (GCP), how can we get a list of all existing projects (for example) ? There are a number of good posts out there about this, so I’m not presenting anything especially novel here. But - if nothing else - hopefully this will be useful to others, and I’m recording it here for posterity.

Pulling GCP IAM information typically means dealing with how GCP effectively uses Projects as a boundary/encapsulation. Which requires a multi-step approach, such as follows:

# gcloud list all projects in root folder of organization in GCP:
gcloud alpha projects search --query="parent.id=<tenant_ID_Here"

gcloud projects list --filter 'parent.id=<id_here> \
 AND parent.type=organization' | awk '{print $1 }' > projects.txt

And from there, reference the following with something like:

for Project in projects.txt; do gcloud projects get-iam-policy Project; done

Originally posted December, 2023

Related