0
0
GCPcloud~10 mins

Roles (basic, predefined, custom) in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign the basic Viewer role to a user in GCP.

GCP
gcloud projects add-iam-policy-binding my-project --member='user:alice@example.com' --role=[1]
Drag options to blanks, or click blank then click option'
Aroles/viewer
Broles/editor
Croles/owner
Droles/customRole
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'roles/editor' which grants edit permissions instead of read-only.
Using 'roles/owner' which grants full control.
Using a custom role name instead of a predefined basic role.
2fill in blank
medium

Complete the code to assign the predefined Compute Admin role to a service account.

GCP
gcloud projects add-iam-policy-binding my-project --member='serviceAccount:my-sa@my-project.iam.gserviceaccount.com' --role=[1]
Drag options to blanks, or click blank then click option'
Aroles/viewer
Broles/compute.admin
Croles/storage.admin
Droles/logging.viewer
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing storage or logging roles instead of compute roles.
Using basic roles instead of predefined roles for specific services.
3fill in blank
hard

Fix the error in the custom role creation command by selecting the correct flag for the role ID.

GCP
gcloud iam roles create myCustomRole [1]='myCustomRoleId' --project=my-project --title='My Custom Role' --permissions=storage.buckets.get
Drag options to blanks, or click blank then click option'
A--id
B--role
C--role-id
D--name
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--role' which is for specifying predefined roles.
Using '--id' or '--name' which are not valid flags for this command.
4fill in blank
hard

Fill both blanks to create a custom role with the correct permissions and assign it to a user.

GCP
gcloud iam roles create myCustomRole --project=my-project --title='Custom Role' --permissions=[1] && gcloud projects add-iam-policy-binding my-project --member='user:bob@example.com' --role=[2]
Drag options to blanks, or click blank then click option'
Astorage.buckets.get
Broles/myCustomRole
Cstorage.objects.list
Droles/storage.admin
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a predefined role instead of the custom role.
Using permissions list instead of role name when assigning.
5fill in blank
hard

Fill all three blanks to list all roles in a project, filter for custom roles, and describe one role.

GCP
gcloud iam roles list --project=my-project --filter='[1]' --format='value(name)' | grep '[2]' | xargs gcloud iam roles describe [3] --project=my-project
Drag options to blanks, or click blank then click option'
Astage:GA
BcustomRoles
Croles/myCustomRole
Dpredefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predefined' instead of 'customRoles' to filter.
Describing role without full name including 'roles/'.