How to create service account from cloud shell | GCP

Service Accounts in Google Cloud are special types of accounts, that belong to applications or VMs instead of an end user. Following tutorial will show how to create service-accounts with cloud-shell in GCP.

Login to Google Cloud Console

Click Activate Cloud Shell to open Cloud Shell.

Set project in GCP cloud shell, replace [Project-ID] with your project ID.


gcloud config set project [Project-ID]

Check updated project ID with $DEVSHELL_PROJECT_ID


echo $DEVSHELL_PROJECT_ID

Create service account


gcloud iam service-accounts create gcptutorials-sa --display-name "gcptutorials service account"

List all the service accounts


gcloud iam service-accounts list

Grant storage.objectViewer role to newly created service account


gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID \
    --member serviceAccount:gcptutorials-sa@$DEVSHELL_PROJECT_ID.iam.gserviceaccount.com --role roles/storage.objectViewer

Categories: GCP