An automated background process running outside Google Cloud needs to publish event telemetry messages to a single Cloud Pub/Sub topic in a project. Following Google Cloud security best practices and the principle of least privilege, which role assignment should be configured?
- Grant the Pub/Sub Publisher (roles/pubsub.publisher) role on the specific Pub/Sub topic to the service account used by the process.Answer
- BGrant the primitive Editor (roles/editor) role on the project to ensure the process can create and manage all messaging resources.
- CGrant the Pub/Sub Admin (roles/pubsub.admin) role at the project level so the process has full administrative control over messaging.
- DDeny access at the project level and grant the Pub/Sub Publisher role at the topic level to override inherited permissions.
Answer
Grant the predefined Pub/Sub Publisher (roles/pubsub.publisher) role to the service account specifically on the target Cloud Pub/Sub topic resource.
Granting the predefined Pub/Sub Publisher role on the specific topic provides exactly the permissions required to publish messages without granting unnecessary administrative access or access to other project resources.
Step-by-Step Solution
Key Concept
Principle of Least Privilege using Predefined IAM Roles at Resource Level Scope