A developer is building a Node.js microservice deployed to Cloud Run that needs to programmatically publish telemetry messages to a Google Cloud Pub/Sub topic. Which authentication approach should the developer use to allow the Google Cloud Client Library to interact with Pub/Sub securely?
- Rely on Application Default Credentials (ADC) by letting the client library automatically retrieve identity tokens from the Cloud Run metadata server.Cevap
- BGenerate a service account JSON key file, embed it directly inside the application container image, and load it into the client library.
- CGrant the primitive Owner role to the Cloud Run default service account so that API calls bypass IAM authorization restrictions.
- DGenerate a service account key using Terraform and commit the unencrypted Terraform state file to the application code repository for runtime credential fetching.
Cevap
Rely on Application Default Credentials (ADC) by letting the client library automatically retrieve identity tokens from the Cloud Run metadata server.
The correct option uses Application Default Credentials (ADC), which allows Google Cloud Client Libraries to automatically fetch short-lived access tokens directly from the runtime container's metadata server without embedding static keys.
Adım Adım Çözüm
Anahtar Kavram
Application Default Credentials (ADC) and Metadata Server Authentication