Soru

Zorluk: ZorManaging IAM Roles and Resource Access Permissions

An Associate Cloud Engineer needs to configure granular access controls for an automated deployment service account by creating a new project-level custom IAM role and granting it to the service account. Which sequence of steps represents the correct procedure to implement this using the gcloud command-line tool?

  1. 1Define the custom IAM role properties, including title, description, launch stage, and specific permissions, inside a local YAML file.
  2. 2Execute `gcloud iam roles create` referencing the project ID and the local YAML file to instantiate the custom role.
  3. 3Run `gcloud iam roles describe` with the project custom role name to verify the role state and assigned permission list.
  4. 4Execute `gcloud projects add-iam-policy-binding` specifying the project ID, the service account principal, and the full custom role ID.

Cevap

The correct operational order is: First, define the custom role properties in a local YAML configuration file. Second, create the project-level custom role using `gcloud iam roles create`. Third, verify the created role details with `gcloud iam roles describe`. Fourth, assign the custom role to the target service account using `gcloud projects add-iam-policy-binding`.
Creating and applying a custom IAM role requires a strict workflow: first defining the permission schema in a file, creating the role resource at the desired level of the hierarchy using `gcloud iam roles create`, validating the resource via `gcloud iam roles describe`, and lastly modifying the resource's IAM policy binding to attach the role to the principal via `gcloud projects add-iam-policy-binding`.

Adım Adım Çözüm

1
Draft the custom role definition file
A structured YAML file containing metadata and exact permission strings (such as `compute.disks.create`).
Google Cloud best practice requires defining granular permissions in a declarative format prior to resource creation.
2
Create the custom IAM role in the GCP project
The custom IAM role is created under the path `projects/[PROJECT_ID]/roles/[ROLE_NAME]`.
The role must exist in the target project's IAM registry before it can be assigned to principals.
3
Inspect and verify the custom role status
Confirmation that the role launch stage is active and contains the expected permissions.
Verifying role configuration ensures no typos or missing permissions exist before applying the role to production service accounts.
4
Bind the custom role to the service account principal
An updated IAM policy for the project granting the service account access.
Role creation and role assignment are separate IAM operations; the binding step applies the role to the identity.

Anahtar Kavram

Custom IAM Role Creation and Policy Binding Lifecycle
Bu soruyu puanla