-
Overview
- A special Google account belonging to an application
- A member, WHO, and a resource, WHAT
- Service accounts are granted permissions to a resource
- Authentication is between application and services
- Identified by its email address
- Users are granted the serviceAccountUser role
-
Google Managed
- Represents different Google services
- Automatically granted IAM roles
- e.g. PROJECT_NUMBER-compute@cloudservices.gserviceaccount.com
-
User Managed
- Created for/by the user
- Based on enabled APIs in project
- e.g. PROJECT_NUMBER-compute@developer.gserviceaccount.com
-
Key
- Service account access is maintained by account keys
- Default service account keys are managed by Google
- Custom service accounts can use user managed (custom) keys
- User is responsible for managing public/private key pair
- Google maintains a public copy for verification
- Private key cannot be retrieved by Google
- Google-managed keys can be used
-
Scopes
- Legacy method of granting permissions for default service accounts on an individual instance
- Grant per instance permissions to other GCP resources via the instance
- IAM roles or scopes determines service account permissions for the instance
-
Best Practices
- Rotate user-managed service account keys
- Do not delete service accounts in use by running services
- Create a separate service account for each service
- Name service accounts to reflect use and permissions
- Do not check-in service account keys into source code or leave in download directory
- When using ServiceAccounts treat each app component as a separate trust boundary
- Restrict who can create, manage and access service accounts