Reputation: 4259
I have a number of unused service accounts in gcloud that I want to remove.
Credentialed Accounts
ACTIVE ACCOUNT
* [email protected]
[email protected]
[email protected]
[email protected]
[email protected]
tf-service@mycompany-terraform-admin-20200422.iam.gserviceaccount.com
However, running
gcloud iam service-accounts delete [email protected]
ERROR: (gcloud.iam.service-accounts.delete) PERMISSION_DENIED: Permission iam.serviceAccounts.delete is required to perform this operation on service account projects/-/serviceAccounts/[email protected].
I am the owner of the account. What more permissions do I need?
Aside: I seem to spend >90% of my time with gcp on permissions instead of actually doing stuff and have not been able to find a clear write-up of this. Anyone knows a good explanation on how to use service-accounts effectively.
Upvotes: 0
Views: 1765
Reputation: 537
In order to delete a service account, your permissions must be higher than the editor role (roles/editor
) or you must be granted the Service Account Admin role (roles/iam.serviceAccountAdmin
).
I suggest that you verify the current account that you are using to make sure that the IAM policies set on it respect the minimum that is required for the actions to be completed successfully.
In regards to the use of Service Accounts, I suggest you consider the following docs:
I hope that this is helpful. IAM is very big and can take a bit of time to get just right. Keep in mind that once IAM is set up right, you may not need to look at it again.
Upvotes: 1