Study guide

15.3 Service Account Impersonation & Short-Lived Credentials

Google Cloud Associate Cloud Engineer ACE

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Introduction & Exam Overview

1.1 About the GCP Associate Cloud Engineer Exam 1.2 How to Use This Study Guide & Build a Study Plan

2 Chapter 2: Resource Hierarchy, IAM Basics & Cloud Identity

2.1 The GCP Resource Hierarchy: Organizations, Folders & Projects 2.2 Organization Policies & Granting IAM Roles 2.3 Cloud Identity: Managing Users and Groups

3 Chapter 3: APIs, Quotas & Billing Configuration

3.1 Enabling APIs and Provisioning Cloud Operations Suite 3.2 Assessing and Requesting Quota Increases 3.3 Billing Accounts, Project Linking & Billing Exports 3.4 Billing Budgets and Alerts

4 Chapter 4: Planning Compute & Storage Resources

4.1 Choosing the Right Compute Option: GCE vs. GKE vs. Cloud Run vs. Cloud Functions 4.2 Spot VMs, Custom Machine Types & Cost-Optimized Compute Planning 4.3 Choosing a Data Storage Product: Cloud SQL, BigQuery, Firestore, Spanner & Bigtable 4.4 Cloud Storage Classes & Persistent Disk Types

5 Chapter 5: Planning Network Resources

5.1 Load Balancing Options and Use Cases 5.2 Regional Resource Placement & High Availability Planning 5.3 Network Service Tiers: Premium vs. Standard

6 Chapter 6: Deploying Compute Engine Workloads

6.1 Launching Compute Engine Instances: Disks, SSH Keys & Availability Policies 6.2 Managed Instance Groups, Instance Templates & Autoscaling 6.3 OS Login and VM Manager for Fleet Configuration

7 Chapter 7: Deploying Google Kubernetes Engine Workloads

7.1 Installing and Configuring kubectl 7.2 Deploying GKE Clusters: Autopilot, Regional, Private & GKE Enterprise 7.3 Deploying Containerized Applications to GKE

8 Chapter 8: Deploying Serverless & Event-Driven Applications

8.1 Deploying Applications to Cloud Run and Cloud Functions 8.2 Event-Driven Architectures: Pub/Sub, Cloud Storage Triggers & Eventarc

9 Chapter 9: Deploying Data Solutions

9.1 Deploying Data Products: Cloud SQL, Firestore, Spanner, BigQuery & AlloyDB 9.2 Deploying Pub/Sub, Dataflow & Loading Data into Google Cloud

10 Chapter 10: Deploying Networking Resources & Infrastructure as Code

10.1 Creating VPCs, Subnets & Shared VPC 10.2 Firewall Rules, Cloud VPN & VPC Network Peering 10.3 Infrastructure as Code: Terraform, Config Connector, Cloud Foundation Toolkit & Helm

11 Chapter 11: Managing Compute Engine & GKE in Production

11.1 Connecting to and Managing Running Compute Engine Instances 11.2 Working with Snapshots and Custom Images 11.3 Managing GKE Clusters: Node Pools, Workloads & Artifact Registry Access 11.4 Horizontal and Vertical Pod Autoscaling in GKE

12 Chapter 12: Managing Cloud Run, Storage & Database Operations

12.1 Managing Cloud Run Revisions, Traffic Splitting & Scaling 12.2 Managing and Securing Cloud Storage Objects & Lifecycle Policies 12.3 Querying, Estimating Costs, Backup & Job Monitoring for Databases (Cloud SQL, BigQuery, Spanner, Dataflow)

13 Chapter 13: Networking Operations, Monitoring & Logging

13.1 Networking Operations: Subnets, Static IPs, Cloud DNS & Cloud NAT 13.2 Cloud Monitoring: Alerts, Custom Metrics & Dashboards 13.3 Cloud Logging: Buckets, Log Analytics, Routers & Filtering 13.4 Diagnostics, Ops Agent, Managed Service for Prometheus & Audit Logs

14 Chapter 14: IAM Policies & Role Types

14.1 IAM Policies: Structure, Bindings & Policy Hierarchy 14.2 IAM Role Types: Basic, Predefined & Custom Roles

15 Chapter 15: Service Accounts & Security Configuration

15.1 Creating Service Accounts & Assigning Least-Privilege Permissions 15.2 Assigning Service Accounts to Resources & Managing SA IAM Policies 15.3 Service Account Impersonation & Short-Lived Credentials

16 Chapter 16: Exam Readiness — Scenarios & Test-Day Strategy

16.1 Common ACE Exam Scenarios & Decision Frameworks 16.2 Test-Day Logistics, Time Management & Final Review Checklist

15.3 Service Account Impersonation & Short-Lived Credentials

Key Takeaways Explain This Topic AI

Impersonation (--impersonate-service-account) requires roles/iam.serviceAccountTokenCreator and needs no downloaded key.

OAuth 2.0 access tokens default to a 1-hour lifetime, extendable to 12 hours only via an explicit organization policy constraint.

A service account can hold at most 10 keys, and new organizations created since May 3, 2024 block key creation by default.

Workload Identity Federation exchanges an external identity's own token (GitHub, AWS, Okta, on-prem) for a short-lived Google Cloud credential, eliminating the need for a downloaded key.

GKE Workload Identity Federation requires both an IAM binding (roles/iam.workloadIdentityUser) and a matching KSA annotation -- either alone is not enough.

Last updated: July 2026

Why This Matters

Two official exam-guide bullets sit under domain 5.2: "Managing service account impersonation" and "Creating and managing short-lived service account credentials." Modern Google Cloud security guidance has shifted hard away from downloadable service account keys and toward impersonation and Workload Identity Federation -- expect several scenario questions that reward picking the keyless option over the key-based one.

What Is Impersonation?

Service account impersonation lets an authorized principal (a user or another service account) temporarily "become" a service account and make API calls with its permissions -- without ever downloading a long-lived key file. The permission required is iam.serviceAccounts.getAccessToken , bundled in the Service Account Token Creator role ( roles/iam.serviceAccountTokenCreator ). gcloud storage ls gs://finance-reports \

  • -impersonate-service-account=billing-exporter@acme-prod.iam.gserviceaccount.com
  • You can also set it as a persistent CLI default: gcloud config set auth/impersonate_service_account \
  • billing-exporter@acme-prod.iam.gserviceaccount.com
  • Short-Lived Credentials: The Types and Lifetimes

The Service Account Credentials API issues several kinds of temporary credentials, all generated on demand and never stored on disk long-term:

Credential Type Default Lifetime Extendable? Role Needed

OAuth 2.0 access token 1 hour (3,600 s) Yes, up to 12 hours (43,200 s) with the iam.allowServiceAccountCredentialLifetimeExtension org policy constraint roles/iam.serviceAccountTokenCreator

  • OIDC ID token 1 hour (3,600 s), fixed No roles/iam.serviceAccountOpenIdTokenCreator
  • Self-signed JWT Set by the caller N/A roles/iam.serviceAccountTokenCreator

Federated token (via Workload Identity Federation) Short-lived, minutes to about 1 hour No N/A -- external identity, exchanged via STS

An access token obtained by impersonation has no refresh token -- once it expires, the caller simply repeats the impersonation call to mint a new one. This is a deliberate design choice: nothing long-lived sits on disk to be stolen.

Exam trap: deleting a service account key does not revoke short-lived credentials that were already issued from that key before deletion. If you suspect a key is compromised, deleting the key stops future misuse but does not retroactively invalidate tokens already handed out.

Service Account Keys: The Last Resort

For comparison, keys remain available but are explicitly the least-preferred authentication option:

A service account can hold a maximum of 10 keys .

JSON is the recommended format; P12 exists only for legacy compatibility.

Since May 3, 2024 , new organizations have the iam.disableServiceAccountKeyCreation constraint enforced by default , blocking key creation unless a project is explicitly exempted.

Google's authentication decision order is: (1) user credentials via Application Default Credentials during development, (2) an attached service account for workloads running on Google Cloud, (3) Workload Identity Federation for workloads running outside Google Cloud, and only as a last resort, (4) a downloaded service account key.

Workload Identity Federation

Workload Identity Federation solves the specific problem of external workloads -- a GitHub Actions pipeline, an AWS Lambda function, an on-premises server -- needing to call Google Cloud APIs without ever holding a Google Cloud credential. Instead, it exchanges the workload's existing identity token (from GitHub, AWS, Okta, Active Directory, and similar providers) for a short-lived Google credential:

You create a workload identity pool (one per external environment).

You add a provider inside that pool for the specific identity source (for example, GitHub's OIDC issuer).

The external workload presents its native token; Google's Security Token Service (STS) validates it and returns a federated token.

That federated token is either (a) granted IAM roles directly on Google Cloud resources, or (b) exchanged again, via impersonation, for a token belonging to an intermediary service account .

GKE Workload Identity Federation

Inside GKE, the same idea binds a Kubernetes ServiceAccount (KSA) to a Google Cloud service account (GSA) so Pods get real Google Cloud permissions without mounting a key file into the container. Two things are required together -- neither alone is sufficient: # 1. IAM policy binding granting the KSA permission to impersonate the GSA

  • gcloud iam service-accounts add-iam-policy-binding \
  • GSA_NAME@PROJECT_ID.iam.gserviceaccount.com \
  • -role roles/iam.workloadIdentityUser \
  • -member "serviceAccount:PROJECT_ID.svc.id.goog[NAMESPACE/KSA_NAME]"
  • # 2. Annotation on the KSA linking it to the GSA
  • kubectl annotate serviceaccount KSA_NAME \
  • -namespace NAMESPACE \
  • iam.gke.io/gcp-service-account=GSA_NAME@PROJECT_ID.iam.gserviceaccount.com
  • Exam Scenario

A CI/CD job running in GitHub Actions needs to push container images to Artifact Registry on every merge to main. The team's current pipeline downloads a service account JSON key stored as a GitHub secret. What should the ACE-certified engineer recommend instead?

Configure a workload identity pool and provider trusting GitHub's OIDC token issuer, grant the mapped identity permission to push to Artifact Registry (directly, or via impersonating a scoped service account), and delete the stored key -- removing a long-lived secret from the pipeline entirely.

Takeaways

Impersonation ( --impersonate-service-account ) requires roles/iam.serviceAccountTokenCreator and needs no downloaded key.

OAuth 2.0 access tokens default to a 1-hour lifetime, extendable to 12 hours only via an explicit organization policy constraint.

A service account can hold at most 10 keys, and new organizations created since May 3, 2024 block key creation by default.

Workload Identity Federation exchanges an external identity's own token for a short-lived Google Cloud credential, eliminating the need for a downloaded key.

GKE Workload Identity Federation requires both an IAM binding ( roles/iam.workloadIdentityUser ) and a matching KSA annotation -- either alone is not enough.