A Cloud Engineer needs to create a project-level custom IAM role from a definition file (`custom-role.yaml`) and assign it to a service account (`[email protected]`) in the project `my-project`. Place the required command line operations and configuration steps in the correct chronological order from first to last to enforce least privilege access securely.
- 1Define the target permissions, title, stage, and description inside a local YAML file named `custom-role.yaml`.
- 2Run `gcloud iam roles create CustomRoleID --project=my-project --file=custom-role.yaml` to register the custom role.
- 3Run `gcloud projects add-iam-policy-binding my-project --member="serviceAccount:[email protected]" --role="projects/my-project/roles/CustomRoleID"` to assign permissions.
- 4Verify the updated IAM policy using `gcloud projects get-iam-policy my-project` to confirm successful access granting.
Answer
The correct sequence starts by authoring the `custom-role.yaml` permissions file, followed by creating the custom role in the project with `gcloud iam roles create`, binding the custom role to the service account using `gcloud projects add-iam-policy-binding`, and finally verifying the policy update with `gcloud projects get-iam-policy`.
Creating and granting custom IAM permissions in Google Cloud requires defining the role specification file first, creating the role in the project hierarchy, attaching the role binding to the service account member, and finally auditing the updated IAM policy.
Step-by-Step Solution
Key Concept
Managing IAM Roles and Resource Access Permissions