PROFESSIONAL-CLOUD-NETWORK-ENGINEER · Question #13
You have recently been put in charge of managing identity and access management for your organization. You have several projects and want to use scripting and automation wherever possible. You want…
The correct answer is B. setIamPolicy() via REST API D. gcloud projects add-iam-policy-binding Sprojectname --member user:Susername --role. To grant a role programmatically, you need a method that writes IAM policy bindings. (B) setIamPolicy() via the REST API directly sets the IAM policy for a resource, enabling role assignment. (D) gcloud projects add-iam-policy-binding is the correct gcloud command to add a role…
Question
Options
- AGetIamPolicy() via REST API
- BsetIamPolicy() via REST API
- Cgcloud pubsub add-iam-policy-binding Sprojectname --member user:Susername -- role
- Dgcloud projects add-iam-policy-binding Sprojectname --member user:Susername --role
- EEnter an email address in the Add members field, and select the desired role from the drop-down
How the community answered
(25 responses)- A8% (2)
- B84% (21)
- C4% (1)
- E4% (1)
Explanation
To grant a role programmatically, you need a method that writes IAM policy bindings. (B) setIamPolicy() via the REST API directly sets the IAM policy for a resource, enabling role assignment. (D) gcloud projects add-iam-policy-binding is the correct gcloud command to add a role binding to a project for a specific member - suitable for scripting and automation. Option A (getIamPolicy) only reads the current policy; it cannot grant roles. Option C uses gcloud pubsub add-iam-policy-binding, which applies to Pub/Sub topics, not projects - wrong resource type. Option E is a manual UI action in the Cloud Console and is not scriptable.
Topics
Community Discussion
No community discussion yet for this question.