gcloud projects list: List Accessible Projects
gcloud projects list enumerates the projects the active account is allowed to see.
Confirming which project a federated identity can reach, or scripting across several, starts with listing them. --filter and --format make it precise.
What it does
gcloud projects list returns the projects the active credentials can access, with their project ID, name, and number. --filter narrows the set and --format reshapes the output for scripting.
Common usage
gcloud projects list
# only active projects, IDs only
gcloud projects list \
--filter='lifecycleState:ACTIVE' \
--format='value(projectId)'Flags
| Flag | What it does |
|---|---|
| --filter <expr> | Filter, e.g. lifecycleState:ACTIVE or name:prod* |
| --format <fmt> | Output format, e.g. value(projectId) |
| --sort-by <field> | Sort the result rows |
| --limit <n> | Cap the number of projects returned |
In CI
Use --format=value(projectId) when looping over projects in a script. After Workload Identity Federation, an empty list often means the impersonated service account has access to fewer projects than your human account does, which is expected.
Common errors in CI
"Cloud Resource Manager API has not been used in project ... or it is disabled" means enable cloudresourcemanager.googleapis.com. An empty list with no error usually means the identity simply has no project-level access. "PERMISSION_DENIED" on a specific project means resourcemanager.projects.get is missing there.