On GCP, I'm trying to add "Service Account 2" as a member to "Service Account 1" with this Terraform code below:
resource "google_service_account" "service_account_1" {
display_name = "Service Account 1"
account_id = "service-account-1"
}
resource "google_service_account" "service_account_2" {
display_name = "Service Account 2"
account_id = "service-account-2"
}
resource "google_service_account_iam_binding" "service_account_iam_binding" {
service_account_id = google_service_account.service_account_1.name
role = "roles/run.invoker"
members = [
"serviceAccount:${google_service_account.service_account_2.email}"
]
depends_on = [
google_service_account.service_account_1,
google_service_account.service_account_2
]
}
But I got this error below:
Error applying IAM policy for service account 'projects/myproject-173831/serviceAccounts/service-account-1@myproject-173831.iam.gserviceaccount.com': Error setting IAM policy for service account 'projects/myproject-173831/serviceAccounts/service-account-1@myproject-173831.iam.gserviceaccount.com': googleapi: Error 400: Role roles/run.invoker is not supported for this resource., badRequest
Are there any mistakes with my Terraform code?