Careeroza
Service Accounts
Identities for Applications
A service account is an identity for a workload (a VM, a Cloud Run service, a CI pipeline), not a person. Give each app its own service account with only the roles it needs.
Example
Create one for an API that only reads files from a bucket:
gcloud iam service-accounts create course-api --display-name "Course API"
gcloud storage buckets add-iam-policy-binding gs://course-media \
--member="serviceAccount:[email protected]" \
--role="roles/storage.objectViewer"Example output
Created service account [course-api].
Avoid Service Account Keys
Note: Downloaded JSON keys are long-lived secrets that leak easily. On Google Cloud, attach the service account to the resource (Cloud Run, VM) and the client libraries authenticate automatically. From GitHub Actions or other clouds, use Workload Identity Federation instead of keys.
Tip: For local development, gcloud auth application-default login lets client libraries use your own account.