An enterprise application hosted on Compute Engine instances in project `telemetry-prod` needs to publish metrics to a Cloud Pub/Sub topic residing in project `shared-monitoring-prod`. To adhere to security directives requiring keyless identity delegation across projects, the source service account `[email protected]` must obtain short-lived credentials for the target service account `[email protected]`. Which IAM configuration correctly enables this cross-project impersonation while following the principle of least privilege?
- Grant the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) to `[email protected]` on the resource `[email protected]`.Answer
- BExport a JSON private key for `[email protected]` and store it securely in the environment variables of the Compute Engine instances.
- CGrant the Project Owner role (`roles/owner`) to `[email protected]` at the `shared-monitoring-prod` project level.
- DRevoke IAM permissions on `[email protected]` at the target project level to force default permission evaluation from a parent folder.
Answer
Grant the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) to `[email protected]` directly on the target service account `[email protected]`.
To configure service account impersonation, the calling identity must be granted the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) directly on the target service account resource. This setup allows `vm-worker` to generate short-lived tokens for `pubsub-publisher` without requiring static credentials or project-wide administrative rights.
Step-by-Step Solution
Key Concept
Service Account Impersonation via IAM Token Creator Role