
Answer-first summary for fast verification
Answer: setIamPolicy() via REST API, gcloud projects add-iam-policy-binding Sprojectname --member user:Susername --role roles/editor
To grant the Editor role at the project level using automation/scripting, two valid methods are: 1. **setIamPolicy() via REST API (B)**: This method allows programmatically updating the IAM policy by modifying the policy and applying it to the project. 2. **gcloud projects add-iam-policy-binding (D)**: This CLI command directly adds the IAM binding for the specified role (roles/editor) at the project level. Option C is incorrect because it targets Pub/Sub resources, not the project. Option E involves the GCP Console, which is manual and not automation. Option A retrieves the policy but does not modify it.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You are managing identity and access management (IAM) for your organization with multiple projects and want to automate role assignments. You need to grant the Editor role to a project member.
Which two methods can you use to achieve this? (Choose two.)
A
GetIamPolicy() via REST API
B
setIamPolicy() via REST API
C
gcloud pubsub add-iam-policy-binding Sprojectname --member user:Susername --role roles/editor
D
gcloud projects add-iam-policy-binding Sprojectname --member user:Susername --role roles/editor
E
Enter an email address in the Add members field, and select the desired role from the drop-down menu in the GCP Console.
No comments yet.