I'm using Terraform to automate a lot of my GCP management because clicking is bad. I've got a "shared services" project that I'm trying to use to manage other projects. I'm trying to setup a new environment in another project and need a service account in the shared services project to manage the resources there. (I don't want to by-hand create a new service account for each project)
I'm trying to create a service account in the new project using the shared services service account. The shared services account has organization-level permissions, but I've been trying to add project-level permissions to fix the issue.
Here's the output of gcloud projects get-iam-policy newproject
(irrelevant info removed, renamed):
bindings:
- members:
- serviceAccount:terraform@shared-services-####.iam.gserviceaccount.com
role: roles/editor
- members:
- serviceAccount:terraform@shared-services-####.iam.gserviceaccount.com
role: roles/iam.serviceAccountAdmin
- members:
- serviceAccount:terraform@shared-services-####.iam.gserviceaccount.com
role: roles/iam.serviceAccountKeyAdmin
- members:
- serviceAccount:terraform@shared-services-####.iam.gserviceaccount.com
role: roles/resourcemanager.projectIamAdmin
etag: BwWGI28ti_w=
version: 1
Here's the output I get attempting to run a test command:
> gcloud iam service-accounts get-iam-policy [email protected] --project=newproject --impersonate-service-account=terraform@shared-services-####.iam.gserviceaccount.com
WARNING: This command is using service account impersonation. All API calls will be executed as [terraform@shared-services-####.iam.gserviceaccount.com].
ERROR: (gcloud.iam.service-accounts.get-iam-policy) PERMISSION_DENIED: The caller does not have permission
The permissions reference states that roles/iam.serviceAccountAdmin
provides this permission.
Here's the output that Terraform gives me (I know it's a different operation):
Error 403: Permission iam.serviceAccounts.get is required to perform this operation on service account projects/-/serviceAccounts/[email protected]., forbidden
I did create the new service account by hand for this specific case because I haven't setup the rest of the infrastructure yet (which would create the account as part of its process). I wanted to make sure this worked.
Any ideas? As far as I can tell, I've granted the permissions it's telling me I need. Help?
Edit: Oh, I checked out trying the API, and I get a 403 as my user account, which should have organization admin:
{
"error": {
"code": 403,
"message": "Permission iam.serviceAccounts.get is required to perform this operation on service account projects/-/serviceAccounts/[email protected].",
"status": "PERMISSION_DENIED"
}
}
I am thoroughly confused