Question

Difficulty: EasySecrets Management and Service Account Lifecycle Security

An application running on a Google Compute Engine virtual machine requires read access to an Google Cloud Storage bucket. To adhere to security best practices for service account lifecycle management, the security team prohibits downloading long-lived service account key files. Which approach should you use to securely authenticate the application to Cloud Storage?

  1. Attach a service account with the required Cloud Storage permissions directly to the Compute Engine instance and authenticate using Application Default Credentials (ADC).Answer
  2. B
    Create a service account key file in JSON format, download it to the VM, and reference its local file path in the application code.
  3. C
    Grant the primitive Owner role to the default Compute Engine service account to eliminate identity configuration requirements.
  4. D
    Assign the Service Account Admin role to the VM's service account so it can dynamically generate new service account keys at runtime.

Answer

Attaching a service account directly to the Compute Engine instance and using Application Default Credentials (ADC) is the Google-recommended keyless authentication method.
Attaching a custom service account to a Compute Engine instance enables keyless authentication through the metadata server. Application Default Credentials (ADC) automatically fetch short-lived access tokens, ensuring robust service account lifecycle security without long-lived exported keys.

Step-by-Step Solution

1
Identify the authentication requirement
The application needs access to Cloud Storage without using downloadable long-lived service account keys.
Security governance strictly forbids downloading key files due to leak risks.
2
Apply Google Cloud native identity mechanisms
Assign a dedicated service account to the VM instance metadata.
Compute Engine automatically generates and rotates short-lived credentials accessible via the internal metadata server.
3
Leverage Application Default Credentials in application logic
The application automatically inherits permissions granted to the attached service account.
ADC seamlessly retrieves short-lived OAuth 2.0 access tokens without explicit key management.

Key Concept

Keyless Authentication via Attached Service Accounts and Application Default Credentials
Rate this question