ASSOCIATE-CLOUD-ENGINEER · Question #86
You are working on a project named amazon-ace, and want to list all the roles assigned to users in the project. Which of the following gcloud command would you use?
The correct answer is C. gcloud projects get-iam-policy amazon-ace. To view all roles assigned to users within a specific Google Cloud project, the gcloud projects get-iam-policy command is used, specifying the project name.
Question
Options
- Agcloud iam list amazon-ace
- Bgcloud projects list amazon-ace
- Cgcloud projects get-iam-policy amazon-ace
- Dgcloud iam get-iam-policy amazon-ace
How the community answered
(30 responses)- A3% (1)
- C93% (28)
- D3% (1)
Why each option
To view all roles assigned to users within a specific Google Cloud project, the `gcloud projects get-iam-policy` command is used, specifying the project name.
The `gcloud iam list` command is not a valid or standard `gcloud` command for listing IAM policies on a project.
The `gcloud projects list` command lists projects themselves, not the IAM policies or roles assigned within a specific project.
The `gcloud projects get-iam-policy` command is designed to retrieve the IAM policy for a specified Google Cloud project, which includes all the roles assigned to users and service accounts within that project. By providing the project name `amazon-ace`, this command will output the complete IAM bindings for the project, showing who has what roles.
The `gcloud iam get-iam-policy` command is used to get IAM policies for resources other than projects, such as a service account or a specific resource, not directly for a project itself with this syntax; `gcloud projects get-iam-policy` is the correct project-specific command.
Concept tested: Listing project IAM policies with gcloud
Source: https://cloud.google.com/sdk/gcloud/reference/projects/get-iam-policy
Topics
Community Discussion
No community discussion yet for this question.