Courseiva
hardMultiple ChoiceObjective-mapped

Using a Compute Engine Attached Service Account for Short-Lived Credentials Without Keys

A financial services company is migrating its on-premises application to Google Cloud. The application needs to access a Cloud SQL instance and a Cloud Storage bucket. Security requirements mandate that the application must use short-lived credentials and avoid storing long-lived service account keys. The application runs on Compute Engine. What should the Security Engineer do to meet these requirements?

Quick Answer

The correct answer is to attach a service account to the Compute Engine instance with appropriate roles for Cloud SQL and Cloud Storage. This works because the instance’s attached service account enables the application to automatically obtain short-lived credentials from the metadata server at 169.254.169.254, eliminating the need to store or distribute long-lived service account keys. On the Google Professional Cloud Security Engineer exam, this scenario tests your understanding of how Compute Engine service account short-lived credentials integrate with IAM and application default credentials, a core concept for secure keyless authentication. A common trap is assuming a custom service account key must be generated and stored on the instance, which violates the security requirement. Remember the memory tip: “Attach, don’t stash” — attach the service account to the VM rather than stashing a key file, and the metadata server handles the rest.

⚠ Common exam trap

Google Cloud often tests the distinction between Compute Engine's native service account attachment (which provides short-lived tokens via metadata server) and external identity federation methods, leading candidates to incorrectly choose Workload Identity Federation for internal workloads.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Attach a service account to the Compute Engine instance with appropriate roles for Cloud SQL and Cloud Storage.

Attaching a service account directly to a Compute Engine instance allows the application to automatically obtain short-lived access tokens from the instance metadata server (http://169.254.169.254) for accessing Cloud SQL and Cloud Storage. This approach eliminates the need to store long-lived service account keys, meeting the security requirement for short-lived credentials.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Create a service account and use Workload Identity Federation to impersonate it.

    Why it's wrong here

    Workload Identity Federation is for external identities, not needed for Compute Engine.

  • Use Cloud Key Management Service to generate and rotate keys for the service account.

    Why it's wrong here

    This still requires a long-lived key.

  • Attach a service account to the Compute Engine instance with appropriate roles for Cloud SQL and Cloud Storage.

    Why this is correct

    Compute Engine automatically obtains short-lived tokens via the metadata server.

  • Create a service account key and store it in Cloud Secret Manager.

    Why it's wrong here

    Service account keys are long-lived and violate the requirement.

About these practice questions

Courseiva writes every PCSE question from scratch — 960 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on PCSE

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which two authentication methods are available for applications to authenticate to Google Cloud APIs without using a service account key? (Choose TWO.)

easy
  • A.API key
  • B.Compute Engine metadata server default service account token
  • C.OAuth 2.0 client ID
  • D.Workload Identity Federation
  • E.Service account key

Why B: The Compute Engine metadata server provides a default service account token that applications running on Compute Engine can use to authenticate to Google Cloud APIs without needing to manage a service account key file. This token is automatically obtained from the metadata server at http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token, and it is rotated automatically by Google, eliminating the need for key storage and rotation.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCSE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCSE exam.