Bird
Raised Fist0
GCPcloud~20 mins

Custom roles creation in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Custom Roles Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Custom Role Permissions Scope

You create a custom role in Google Cloud Platform (GCP). Which statement correctly describes the scope of permissions you can assign to this custom role?

AYou can assign permissions only if you have Owner role on the project.
BYou can only assign permissions from services enabled in your project or organization.
CYou can assign permissions only from the Compute Engine service.
DYou can assign any permissions available in GCP, including those from services not enabled in your project.
Attempts:
2 left
💡 Hint

Think about whether permissions depend on enabled services or the full GCP permission set.

❓ Configuration
intermediate
2:00remaining
Valid JSON for Creating a Custom Role

Which JSON snippet correctly defines a custom role with title 'Data Viewer', description 'Can view data', and permissions to read BigQuery datasets?

A
{
  "roleId": "dataViewer",
  "role": {
    "title": "Data Viewer",
    "description": "Can view data",
    "includedPermissions": ["bigquery.datasets.get", "bigquery.tables.get"]
  }
}
B
{
  "roleId": "dataViewer",
  "role": {
    "title": "Data Viewer",
    "description": "Can view data",
    "permissions": ["bigquery.datasets.get", "bigquery.tables.get"]
  }
}
C
{
  "id": "dataViewer",
  "role": {
    "title": "Data Viewer",
    "description": "Can view data",
    "includedPermissions": ["bigquery.datasets.get"]
  }
}
D
{
  "roleId": "dataViewer",
  "title": "Data Viewer",
  "description": "Can view data",
  "includedPermissions": ["bigquery.datasets.get", "bigquery.tables.get"]
}
Attempts:
2 left
💡 Hint

Check the correct key names for permissions and role ID in the JSON structure.

❓ Architecture
advanced
2:00remaining
Best Practice for Custom Role Assignment Scope

You want to assign a custom role to users but limit their permissions only to a specific project. Which is the best practice to achieve this?

ACreate the custom role at the project level and assign it at the project level.
BCreate the custom role at the project level and assign it at the organization level.
CCreate the custom role at the organization level and assign it at the project level.
DCreate the custom role at the folder level and assign it at the organization level.
Attempts:
2 left
💡 Hint

Consider where the role is created and where it is assigned to limit scope.

❓ security
advanced
2:00remaining
Security Risk of Overly Broad Custom Roles

What is a key security risk when creating a custom role that includes too many permissions?

AUsers may be unable to perform any actions due to lack of permissions.
BThe custom role will automatically be disabled by GCP security checks.
CUsers may gain unintended access to sensitive resources, increasing risk of data leaks.
DThe custom role will cause billing to increase automatically.
Attempts:
2 left
💡 Hint

Think about what happens if users have more permissions than needed.

❓ service_behavior
expert
2:00remaining
Effect of Deleting a Custom Role in Use

What happens immediately after deleting a custom role that is currently assigned to users in GCP?

AUsers keep the permissions from the deleted custom role until their next login, then lose them.
BUsers immediately lose all permissions granted by the deleted custom role.
CUsers keep the permissions permanently even after role deletion.
DGCP automatically replaces the deleted custom role with a predefined role.
Attempts:
2 left
💡 Hint

Consider how GCP enforces permissions when roles are removed.

Practice

(1/5)
1. What is the main purpose of creating a custom role in Google Cloud Platform?
easy
A. To create virtual machines quickly
B. To automatically assign all permissions to a user
C. To delete existing predefined roles
D. To tailor permissions specifically for your project needs

Solution

  1. Step 1: Understand role customization

    Custom roles allow you to pick specific permissions instead of using broad predefined roles.
  2. Step 2: Identify the purpose of custom roles

    They help tailor access to exactly what is needed, improving security and management.
  3. Final Answer:

    To tailor permissions specifically for your project needs -> Option D
  4. Quick Check:

    Custom roles = tailored permissions [OK]
Hint: Custom roles = pick permissions you want [OK]
Common Mistakes:
  • Thinking custom roles give all permissions automatically
  • Confusing custom roles with deleting roles
  • Assuming custom roles create resources
2. Which of the following is the correct gcloud command syntax to create a custom role named myCustomRole in project my-project with the title "My Role" and permission storage.buckets.list?
easy
A. gcloud iam roles create myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list --stage=GA
B. gcloud iam create role myCustomRole --project my-project --title My Role --permissions storage.buckets.list
C. gcloud roles create myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list
D. gcloud iam roles add myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list

Solution

  1. Step 1: Identify correct gcloud command structure

    The correct command to create a custom role is gcloud iam roles create with flags for project, title, permissions, and stage.
  2. Step 2: Match syntax with options

    gcloud iam roles create myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list --stage=GA matches the correct syntax including --project, --title, --permissions, and --stage flags.
  3. Final Answer:

    gcloud iam roles create myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list --stage=GA -> Option A
  4. Quick Check:

    Correct gcloud create syntax = gcloud iam roles create myCustomRole --project=my-project --title="My Role" --permissions=storage.buckets.list --stage=GA [OK]
Hint: Use 'gcloud iam roles create' with all flags [OK]
Common Mistakes:
  • Using 'gcloud iam create role' instead of 'roles create'
  • Missing the --stage flag
  • Incorrect flag order or missing equal signs
3. Given this command:
gcloud iam roles create dataViewer --project=my-project --title="Data Viewer" --permissions=bigquery.datasets.get,bigquery.tables.list --stage=ALPHA

What will be the effect of this custom role?
medium
A. Allows users to get dataset metadata and list tables in BigQuery
B. Allows users to create and delete BigQuery datasets
C. Grants full admin access to BigQuery
D. Denies all BigQuery permissions

Solution

  1. Step 1: Analyze permissions in the command

    The permissions bigquery.datasets.get and bigquery.tables.list allow reading dataset info and listing tables.
  2. Step 2: Understand what these permissions enable

    These permissions let users view dataset metadata and see tables but not modify or delete them.
  3. Final Answer:

    Allows users to get dataset metadata and list tables in BigQuery -> Option A
  4. Quick Check:

    Permissions = read-only BigQuery access [OK]
Hint: Check permissions list for read or write actions [OK]
Common Mistakes:
  • Assuming ALPHA stage means full access
  • Confusing get/list with create/delete permissions
  • Thinking it grants admin rights
4. You tried to create a custom role with this command:
gcloud iam roles create testRole --project=my-project --title="Test Role" --permissions=compute.instances.start,compute.instances.stop

But it failed. What is the most likely reason?
medium
A. Project ID is incorrect
B. Permissions are invalid for custom roles
C. Missing the --stage flag which is required
D. Role ID cannot contain uppercase letters

Solution

  1. Step 1: Check required flags for role creation

    The --stage flag is mandatory when creating custom roles to specify the release stage.
  2. Step 2: Identify missing flag in the command

    The command lacks the --stage flag, causing failure.
  3. Final Answer:

    Missing the --stage flag which is required -> Option C
  4. Quick Check:

    --stage flag required = Missing the --stage flag which is required [OK]
Hint: Always include --stage when creating custom roles [OK]
Common Mistakes:
  • Ignoring the required --stage flag
  • Assuming permissions are invalid
  • Mistaking project ID or role ID format
5. You want to create a custom role that allows users to list storage buckets and read objects but not delete them. Which permissions should you include in your custom role?
hard
A. storage.buckets.list, storage.objects.delete
B. storage.buckets.list, storage.objects.get
C. storage.buckets.create, storage.objects.get
D. storage.buckets.delete, storage.objects.get

Solution

  1. Step 1: Identify permissions for listing buckets and reading objects

    storage.buckets.list allows listing buckets, and storage.objects.get allows reading objects.
  2. Step 2: Exclude delete permissions

    Do not include any delete permissions to prevent deletion.
  3. Final Answer:

    storage.buckets.list, storage.objects.get -> Option B
  4. Quick Check:

    List + read, no delete = storage.buckets.list, storage.objects.get [OK]
Hint: Include only list and get permissions, exclude delete [OK]
Common Mistakes:
  • Including delete permissions by mistake
  • Confusing create with list permissions
  • Assuming read includes delete
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard