Why doesn't Cloud Build service account show up in gcloud list command?

When I look at the Console IAM dashboard for my project I can see the line item for my Cloud Build Service Account:

https://console.cloud.google.com/iam-admin/iam

Member                                           Role
[email protected]        Cloud Build Service Account

But when I list service accounts with the gcloud command the service account doesn't show up:

$ gcloud iam service-accounts list --project=$PROJECT
Listed 0 items.

Why is the [email protected] service account showing up?


Solution 1:

The command below only shows the User-managed service accounts. (There are three types of Service Account in GCP) And you can see that list by going to your cloud console > IAM & Admin > Service Accounts.

gcloud iam service-accounts list --project=$PROJECT

If you want to show all types of Service Accounts that you see under IAM & Admin > IAM you will need to use the command below:

gcloud projects get-iam-policy $PROJECT-ID

To know more about this topic, you can check the official GCP documentation about Service Accounts.