简体   繁体   中英

(GCP, Terraform) Error creating service account: googleapi: Error 403: Permission iam.serviceAccounts.create is required to perform this operation on

On GCP , I'm trying to create a service account with this Terraform code below:

provider "google" {
  credentials = file("myCredentials.json")
  project     = "myproject-173831"
  region      = "asia-northeast1"
}

resource "google_service_account" "service_account" {
  display_name = "My Service Account"
  account_id   = "my-service-account"
}

But I got this error:

Error creating service account: googleapi: Error 403: Permission iam.serviceAccounts.create is required to perform this operation on project projects/myproject-173831., forbidden

So now, I'm trying to add a role to solve this error above but there are too many roles to choose:

在此处输入图像描述

What role do I need to choose?

You need to choose the role "Create Service Accounts" to create service accounts:

在此处输入图像描述

In addition, you can choose the role "Delete Service Accounts" to delete service accounts:

在此处输入图像描述

Otherwise, you cannot delete service accounts then you will get this error below:

Error 403: Permission iam.serviceAccounts.delete is required to perform this operation on service account projects/myproject-173831/serviceAccounts/my-service-account@myproject-173831.iam.gserviceaccount.com., forbidden

Finally, if you want to create and delete service accounts with one role, you can choose the more abstract role "Service Account Admin" :

在此处输入图像描述

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