nerdexam
Google

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…

Submitted by yasin.bd· Apr 18, 2026Implementing network security

Question

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 to grant the editor role to a project member. Which two methods can you use to accomplish this? (Choose two.)

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)
  • A
    8% (2)
  • B
    84% (21)
  • C
    4% (1)
  • E
    4% (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

#IAM#gcloud CLI#REST API#Automation

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-NETWORK-ENGINEER Practice