简体   繁体   中英

How to add GCP IAM roles to Service Account

I am trying to create a docker swarm node on a VM instance on GCP using docker-machine .

docker-machine create swarm-node -d google --google-machine-type e2-standard-2 --google-zone europe-north1-a --google-project myproject-name

I use a GCP Service Account in localhost docker-machine CLI.

export GOOGLE_APPLICATION_CREDENTIALS="/home/my-name-here/.gcp/path-to-my-service-account-keyfile.json"

But I got this error:

Error with pre-create check: "Project with ID \"myproject-name\" not found. googleapi: Error 403: Required 'compute.projects.get' permission for 'projects/myproject-name', forbidden"

How can I add compute.projects.get GCP IAM access to the GCP Service Account?

Finally I figured out, as explained at: https://cloud.google.com/iam/docs/granting-changing-revoking-access

  1. In the Cloud Console, go to the IAM page
  2. Click Add.
  3. Enter the service-account email address (displayed in service-account dashboard).
  4. Select a role, in this case Compute Admin
  5. Click Save.

Et voilà

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM