GCP for DevOps — Introduction Exercises
Practice Exercises — Introduction
Test your understanding of GCP fundamentals with these 5 hands-on exercises.
Exercise 1: Create and Configure a Project
Create a new GCP project, set it as your default, and enable the Compute Engine API.
Show Answer
# Create the project
$ gcloud projects create devops-exercise-01 \
--name="DevOps Exercise 01"
# Set it as default
$ gcloud config set project devops-exercise-01
# Link billing (use your billing account ID)
$ gcloud billing projects link devops-exercise-01 \
--billing-account=0X0X0X-0X0X0X-0X0X0X
# Enable Compute Engine API
$ gcloud services enable compute.googleapis.com
# Verify
$ gcloud services list --enabled --filter="name:compute"
NAME
compute.googleapis.com
Exercise 2: Explore Regions and Zones
List all GCP regions, then find all zones in the europe-west1 region. Set europe-west1-b as your default zone.
Show Answer
# List all regions
$ gcloud compute regions list --format="table(name,description)"
NAME DESCRIPTION
asia-east1 Changhua County, Taiwan
europe-west1 St. Ghislain, Belgium
us-central1 Council Bluffs, Iowa, USA
...
# List zones in europe-west1
$ gcloud compute zones list --filter="region:europe-west1"
NAME REGION STATUS
europe-west1-b europe-west1 UP
europe-west1-c europe-west1 UP
europe-west1-d europe-west1 UP
# Set default zone
$ gcloud config set compute/zone europe-west1-b
$ gcloud config set compute/region europe-west1
# Verify
$ gcloud config list compute/
[compute]
region = europe-west1
zone = europe-west1-b
Exercise 3: Multiple Configurations
Create two gcloud configurations — one for “dev” and one for “prod” — with different default regions.
Show Answer
# Create dev configuration
$ gcloud config configurations create dev-config
$ gcloud config set project devops-exercise-01
$ gcloud config set compute/region us-central1
$ gcloud config set compute/zone us-central1-a
# Create prod configuration
$ gcloud config configurations create prod-config
$ gcloud config set project devops-exercise-01
$ gcloud config set compute/region us-east1
$ gcloud config set compute/zone us-east1-b
# List configurations
$ gcloud config configurations list
NAME IS_ACTIVE ACCOUNT PROJECT DEFAULT_ZONE DEFAULT_REGION
default False you@example.com my-devops-lab us-central1-a us-central1
dev-config False you@example.com devops-exercise-01 us-central1-a us-central1
prod-config True you@example.com devops-exercise-01 us-east1-b us-east1
# Switch to dev
$ gcloud config configurations activate dev-config
Activated [dev-config].
Exercise 4: Enable Multiple APIs
Enable the following APIs in your project: Cloud Build, Cloud Run, Secret Manager, and Artifact Registry. Then list all enabled APIs.
Show Answer
# Enable APIs
$ gcloud services enable \
cloudbuild.googleapis.com \
run.googleapis.com \
secretmanager.googleapis.com \
artifactregistry.googleapis.com
Operation "operations/abc123" finished successfully.
# List enabled APIs (filter for the ones we just enabled)
$ gcloud services list --enabled \
--format="table(name)" \
--filter="name:(cloudbuild OR run OR secretmanager OR artifactregistry)"
NAME
artifactregistry.googleapis.com
cloudbuild.googleapis.com
run.googleapis.com
secretmanager.googleapis.com
Exercise 5: Explore Project Details
Get detailed information about your project including the project number, creation time, and current IAM policy. Output the project number only.
Show Answer
# Full project details
$ gcloud projects describe devops-exercise-01
createTime: '2026-03-30T07:00:00.000Z'
lifecycleState: ACTIVE
name: DevOps Exercise 01
parent:
id: '123456789012'
type: organization
projectId: devops-exercise-01
projectNumber: '345678901234'
# Project number only
$ gcloud projects describe devops-exercise-01 \
--format="value(projectNumber)"
345678901234
# Get IAM policy
$ gcloud projects get-iam-policy devops-exercise-01 \
--format="table(bindings.role,bindings.members)"
ROLE MEMBERS
roles/owner user:you@example.com
roles/editor serviceAccount:345678901234-compute@developer.gserviceaccount.com
Cleanup:
# Switch back to default configuration
$ gcloud config configurations activate default
# Delete the exercise project (optional)
$ gcloud projects delete devops-exercise-01 --quiet
Next Chapter → IAM & Security