An integration engineer is configuring access for an external application service account that must send telemetry messages to a specific Google Cloud Pub/Sub topic in a production project. The application should only be capable of publishing messages to this single topic and must not be allowed to read messages, manage subscriptions, or modify any other project resources. To adhere to Google Cloud's recommendation of least privilege, which IAM configuration should be implemented?
- Grant the Pub/Sub Publisher role (`roles/pubsub.publisher`) to the service account directly on the target Pub/Sub topic resource.Answer
- BGrant the primitive Editor role (`roles/editor`) to the service account at the project level.
- CGrant the Pub/Sub Editor role (`roles/pubsub.editor`) to the service account at the project level.
- DGrant the Pub/Sub Viewer role (`roles/pubsub.viewer`) at the project level and rely on default topic permissions to block publishing on other topics.
Answer
Grant the Pub/Sub Publisher role (`roles/pubsub.publisher`) to the service account directly on the target Pub/Sub topic resource.
Granting the Pub/Sub Publisher role (`roles/pubsub.publisher`) directly on the target Pub/Sub topic resource enforces least privilege in two ways: it selects a fine-grained predefined role containing only publish permissions, and it scopes that permission strictly to the designated topic resource.
Step-by-Step Solution
Key Concept
Applying fine-grained predefined IAM roles at the resource level to enforce least privilege.
Estimated Time:1m 30s