Create a service account using gcloud

Vérifier ma progression

/ 20

Grant IAM permissions to service account using gcloud

Vérifier ma progression

/ 20

Create a compute instance with service account attached using gcloud

Vérifier ma progression

/ 20

Create a custom role using a YAML file

Vérifier ma progression

/ 20

Use the client libraries to access BigQuery from a service account

Vérifier ma progression

/ 20

Cet atelier peut intégrer des outils d'IA pour vous accompagner dans votre apprentissage.
Ce contenu n'est pas encore optimisé pour les appareils mobiles.
Pour une expérience optimale, veuillez accéder à notre site sur un ordinateur de bureau en utilisant un lien envoyé par e-mail.

ARC134

Google Cloud self-paced labs

Overview

In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.

When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.

To score 100% you must successfully complete all tasks within the time period!

In this challenge lab, you will be taking help of Gemini to complete the given tasks.

Gemini for Google Cloud is an always-on AI collaborator that provides help to users of all skill levels where they need it. In this lab, you use Gemini to get information you need to create resources in the tasks.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

Activate Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click through the following windows:

    • Continue through the Cloud Shell information window.
    • Authorize Cloud Shell to use your credentials to make Google Cloud API calls.

When you are connected, you are already authenticated, and the project is set to your Project_ID, . The output contains a line that declares the Project_ID for this session:

Your Cloud Platform project in this session is set to {{{project_0.project_id | "PROJECT_ID"}}}

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:
gcloud auth list
  1. Click Authorize.

Output:

ACTIVE: * ACCOUNT: {{{user_0.username | "ACCOUNT"}}} To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:
gcloud config list project

Output:

[core] project = {{{project_0.project_id | "PROJECT_ID"}}} Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Challenge scenario

You are starting your career as a junior cloud architect. In this role, you have been assigned to work on a team project that requires you to use service accounts, configure IAM permissions using the gcloud command line interface (CLI), add custom roles, and use the client libraries to access BigQuery from a service account.

You are expected to have the skills and knowledge to complete the tasks that follow. Also, you can take help from Gemini to identify CLI commands or steps to complete the tasks.

Your challenge

For this challenge, you are asked to create a service account, assign required roles, configure IAM permissions using the gcloud CLI, create a custom role using a YAML file, and use the client libraries to access BigQuery from a service account.

You are asked to:

  • Configure a service account using the gcloud CLI.
  • Grant IAM permissions to a service account using the gcloud CLI.
  • Create a compute instance using the service account.
  • Create a custom role using a YAML file.
  • Use the client libraries to access BigQuery from a service account.

Create all the resources in region and zone.

Each task is described in detail below, good luck!

Task 1. Enable and Explore Gemini (optional)

Note: If you want to use Gemini, follow the steps given below to enable it otherwise you can go directly to Task 2.

Since you are going to use Gemini, let's quickly enable and explore the Gemini.

In this task, you use the Gemini pane to enter prompts and view the responses from Gemini. Prompts are questions or statements that describe the help that you need. Prompts can include context from existing code that Google Cloud analyzes to provide more useful or complete responses. For more information on writing prompts to generate good responses, see Write better prompts for Gemini.

To prompt Gemini about Google Cloud services, perform these steps:

  1. Sign in to the Google Cloud Console.

  2. Click on the Gemini icon (Gemini icon) in the top-right corner of the Google Cloud console toolbar.

  3. Select Get Gemini Cloud Assist at no cost then click Enable Gemini Cloud Assist at no cost to enable the Gemini Cloud Assist API.

  4. Once enabled, click Start Chatting.

Enter the following prompt:

What is service account? What is the difference between predefined roles and custom roles? Note: Gemini doesn't use your prompts or its responses as data to train its model. For more information, see How Gemini in Google Cloud uses your data. Note: As an early-stage technology, Gemini can generate output that seems plausible but is factually incorrect. We recommend that you validate all output from Gemini before you use it. For more information, see Gemini in Google Cloud and responsible AI.

Task 2. Create a service account using the gcloud CLI

For this task, use Cloud Shell to perform the tasks that follow. You will create a service account by taking the help of Gemini.

  1. In Cloud Shell, create a service account named devops.
Note: To create the following resources, you need to click on Click here for hint! and use the prompt in the Gemini to fetch the commands to create the resource.

Click Check my progress to verify the objective. Create a service account using gcloud CLI

Task 3. Grant IAM permissions to a service account using the gcloud CLI

  1. Since you will be using the project id and the service account multiple times, it is a good idea to export the project id and service account into local variables in Cloud Shell.

For this task, you need to assign the required roles to a service account using the gcloud CLI.

  1. Similarly, store the service account email address in a local variable called SA.
  1. To complete this task, in Cloud Shell, give the service account the role of iam.serviceAccountUser with the permissions compute.instanceAdmin.
Note: To create the following resources, you need to click on Click here for hint! and use the prompt in the Gemini to fetch the commands to create the resource.

Click Check my progress to verify the objective. Grant IAM permissions to a service account using gcloud CLI

Task 4. Create a compute instance with a service account attached using gcloud

  1. In Cloud Shell, create a compute instance named vm-2 with the devops service account attached that you created in Task 2.

  2. SSH into the vm-2 VM instance. Try to create and list an instance from vm-2 to verify you have the necessary permissions via the service account.

Note: To create the following resources, you need to click on Click here for hint! and use the prompt in the Gemini to fetch the commands to create the resource.

Click Check my progress to verify the objective. Create a compute instance with a service account attached using gcloud

Task 5. Create a custom role using a YAML file

  1. In Cloud Shell, create a YAML file named role-definition.yaml that has a custom role definition with the permissions cloudsql.instances.connect and cloudsql.instances.get using Gemini.
  1. Execute the gcloud command to create a role at the project level using the YAML file.
Note: To create the following resources, you need to click on Click here for hint! and use the prompt in the Gemini to fetch the commands to create the resource.

Click Check my progress to verify the objective. Create a custom role using a YAML file

Task 6. Use the client libraries to access BigQuery from a service account

For this task, you will query the BigQuery public datasets from an instance with the help of a service account which has the necessary roles configured. Login to the Google Cloud console using the username and password provided.

  1. Create a service account named bigquery-qwiklab and assign it the role of BigQuery Data Viewer and BigQuery User.
  1. Create a VM instance named bigquery-instance using the service account bigquery-qwiklab.
  1. SSH into the bigquery-instance and install the dependencies.
  1. Use the following code to create a Python file.
cat << 'EOF' > query.py from google.auth import compute_engine from google.cloud import bigquery credentials = compute_engine.Credentials( service_account_email='YOUR_SERVICE_ACCOUNT') query = ''' SELECT name, SUM(number) as total_people FROM `bigquery-public-data.usa_names.usa_1910_2013` WHERE state = 'TX' GROUP BY name, state ORDER BY total_people DESC LIMIT 20 ''' client = bigquery.Client( project='YOUR_PROJECT_ID', credentials=credentials) print(client.query(query).to_dataframe()) EOF
  1. Replace the YOUR_PROJECT_ID and YOUR_SERVICE_ACCOUNT variables with your credentials and run the file using a Python3 command:
python3 query.py Note: To create the following resources, you need to click on Click here for hint! and use the prompt in the Gemini to fetch the commands to create the resource.

Click Check my progress to verify the objective. Use the client libraries to access BigQuery from a service account

Congratulations!

Congratulations! You have successfully created Google Cloud service accounts, assigned roles to service accounts, configured IAM permissions using the gcloud CLI, and created a custom role by taking the help of the Gemini Prompt.

Configure Service Accounts and IAM for Google Cloud badge

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated October 27, 2026

Lab Last Tested October 27, 2026

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Avant de commencer

  1. Les ateliers créent un projet Google Cloud et des ressources pour une durée déterminée.
  2. Les ateliers doivent être effectués dans le délai imparti et ne peuvent pas être mis en pause. Si vous quittez l'atelier, vous devrez le recommencer depuis le début.
  3. En haut à gauche de l'écran, cliquez sur Démarrer l'atelier pour commencer.

Utilisez la navigation privée

  1. Copiez le nom d'utilisateur et le mot de passe fournis pour l'atelier
  2. Cliquez sur Ouvrir la console en navigation privée

Connectez-vous à la console

  1. Connectez-vous à l'aide des identifiants qui vous ont été attribués pour l'atelier. L'utilisation d'autres identifiants peut entraîner des erreurs ou des frais.
  2. Acceptez les conditions d'utilisation et ignorez la page concernant les ressources de récupération des données.
  3. Ne cliquez pas sur Terminer l'atelier, à moins que vous n'ayez terminé l'atelier ou que vous ne vouliez le recommencer, car cela effacera votre travail et supprimera le projet.

Ce contenu n'est pas disponible pour le moment

Nous pouvons vous prévenir par e-mail lorsqu'il sera disponible

Parfait !

Nous pouvons vous contacter par e-mail s'il devient disponible

Un atelier à la fois

Confirmez pour mettre fin à tous les ateliers existants et démarrer celui-ci

Utilisez la navigation privée pour effectuer l'atelier

Le meilleur moyen d'exécuter cet atelier consiste à utiliser une fenêtre de navigation privée. Vous éviterez ainsi les conflits entre votre compte personnel et le compte temporaire de participant, qui pourraient entraîner des frais supplémentaires facturés sur votre compte personnel.