Google Cloud Engineer interview question · Most asked
What are service accounts, and how should workloads authenticate without service account keys?
How you'd do it Asked in Cloud Engineer interviews
Summary
A service account is an identity for a workload rather than a person. Workloads on Google Cloud get short-lived credentials automatically by attaching a service account (Compute Engine, Cloud Run, Cloud Run functions) or through Workload Identity Federation for GKE. Workloads outside Google Cloud (GitHub Actions, AWS, on-premises) use Workload Identity Federation to exchange their own tokens for short-lived Google credentials. Downloaded JSON keys are long-lived secrets and should be avoided.
Longer Answer
- New organisations enforce the org policy
iam.disableServiceAccountKeyCreationby default; keep it on. - One service account per workload, with only the roles it needs; don't reuse the Compute Engine default service account (it historically had Editor).
- Impersonation (
roles/iam.serviceAccountTokenCreator,gcloud --impersonate-service-account) lets engineers act as a service account temporarily without keys. - Federation for CI: scope the workload identity pool provider to the exact repository and branch with an attribute condition.
Key Points
- Attach service accounts to workloads.
- Workload Identity Federation for GKE and external workloads.
- Avoid JSON keys; block their creation.
- One account per workload; impersonation for humans.
Explanation
What interviewers look for
Keyless authentication everywhere, and scoping federation tightly.
More Google Cloud Engineer questions
- How do you design a Google Cloud landing zone for a company with several teams?
- How do you run Terraform for Google Cloud safely in a team?
- Explain Google Cloud's resource hierarchy: organisation, folders, projects and resources.
- How does IAM work in Google Cloud, and why should you avoid basic roles?
- Compare Google Cloud's database options: Cloud SQL, AlloyDB, Spanner, Firestore and Bigtable.
- How is networking in a Google Cloud VPC different from AWS?
- When would you choose Cloud Run, GKE or Compute Engine?
- Design a highly available web application on Google Cloud.