DEV Community

Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on

Create a service account in the Google Cloud Platform using the command line:

Use this command to create the service account:

gcloud iam service-accounts create test-service-account2 --display-name "test-service-account2"
Enter fullscreen mode Exit fullscreen mode

Note: If you see the following output, type y and press ENTER

Image description

Now if you go to the Navigation bar and then IAM & Admin and then Service accounts, you can see out service account:

Image description

Also we can give it a role using command line. For example, lets give this service account the project viewer role:

gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT --member serviceAccount:test-service-account2@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com --role roles/viewer
Enter fullscreen mode Exit fullscreen mode

Image description

Done!

Top comments (0)