Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud Security Engineer practice bank has 1,343 more like it. Try 10 free: instant score, no account.
An enterprise is eliminating long-lived service account keys across its development and CI/CD pipelines. A developer needs to invoke a private microservice deployed on Cloud Run (https://orders.example.com) directly from their local environment.
The security requirements are:
order-invoker@corp-project.iam.gserviceaccount.com), which already possesses the Cloud Run Invoker role (roles/run.invoker).Which IAM role and short-lived credential generation process should the security engineer implement?
The Service Account User role (roles/iam.serviceAccountUser) grants the iam.serviceAccounts.actAs permission, which allows a principal to attach a service account to a Google Cloud compute resource (such as a Compute Engine VM, Cloud Run service, or Cloud Build worker).
iam.serviceAccounts.actAs permission does not grant rights to generate short-lived credentials or impersonate service accounts via the IAM Credentials API or gcloud. Credential generation requires iam.serviceAccounts.getAccessToken or iam.serviceAccounts.getOpenIdToken.aud (audience) claim matching the service URL. Generating an OAuth 2.0 access token via generateAccessToken produces an authorization token meant for Google APIs (such as Cloud Storage or BigQuery), which Cloud Run will reject.generateAccessToken method accepts OAuth scopes (e.g., https://www.googleapis.com/auth/cloud-platform), not individual target application endpoint URLs as audience identifiers.roles/iam.serviceAccountUser only governs resource attachment (actAs), not programmatic token generation.A developer needed permission to deploy or instantiate a Compute Engine instance or Cloud Run service configured to execute workloads using that service account identity.
The Service Account Key Admin role (roles/iam.serviceAccountKeyAdmin) grants permissions (iam.serviceAccountKeys.create, iam.serviceAccountKeys.delete, etc.) to create, list, and delete user-managed RSA key pairs (JSON/P12 files) for service accounts.
An external third-party platform that does not support OAuth 2.0, OIDC, or Workload Identity Federation required a static cryptographic private key file for legacy authentication.
The Service Account OpenID Connect Identity Token Creator role (roles/iam.serviceAccountOpenIdTokenCreator) contains the iam.serviceAccounts.getOpenIdToken permission. It specifically allows a principal (such as a developer user identity or CI/CD runner) to impersonate a target privilege-bearing service account exclusively for generating short-lived OIDC ID tokens without granting permissions to generate OAuth 2.0 access tokens or sign arbitrary data.
generateIdToken method on the IAM Credentials API (iamcredentials.googleapis.com) allows the caller to pass the specific Cloud Run service URL in the audience (aud) claim. Cloud Run requires a Google-signed OIDC ID token matching the receiving service's URL to authenticate incoming requests.roles/iam.serviceAccountOpenIdTokenCreator directly on the order-invoker service account resource (rather than at the project level) restricts the developer's impersonation capability strictly to that single identity and specifically to OIDC token creation.https://orders.example.com) and is rejected by other Google APIs or services.This approach directly satisfies all zero-trust requirements: it leverages short-lived identity federation, avoids static keys, strictly limits caller permissions to OIDC generation, and enforces proper cryptographic audience claims required by Cloud Run.
Self-impersonation occurs when a service account is granted the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on its own identity resource. The Compute Engine metadata server is a local HTTP endpoint (http://metadata.google.internal) available inside Google Cloud compute runtimes to provide credentials for attached service accounts.
metadata.google.internal.Code running directly inside a Google Cloud environment (like a Compute Engine VM or Cloud Build step) needed to query its locally attached service account identity without using impersonation chains.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated