How to do it...

We'll first create a service account with default access rights. Next, we'll launch a VM with the newly created service account. Ideally, the VM would not have direct access to Cloud SQL. Then, in IAM we'll assign the Cloud SQL admin rights to our service account and redo our verification:

  1. Launch the Google Cloud Shell from the Console:
  2. We'll create a service account using the following command:
$ gcloud iam service-accounts create my-sa-with-sql --display-name "Service a/c with sql access"
  1. To view all the service accounts, we can use the following command:
$ gcloud iam service-accounts listNAME                             EMAILService a/c with sql access      my-sa-with-sql@upbeat-aura-163616.iam.gserviceaccount.com

The following screenshot shows the ...

Get Google Cloud Platform Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.