Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Service account keys management
📖 Scenario: You are managing a Google Cloud project. You need to create and manage service account keys securely to allow applications to authenticate with Google Cloud services.
🎯 Goal: Build a script that creates a service account key, lists existing keys, and deletes a specified key to keep your project secure.
📋 What You'll Learn
Create a service account key for a given service account
List all keys for the service account
Delete a specific key by its ID
💡 Why This Matters
🌍 Real World
Managing service account keys is essential for securing access to Google Cloud resources by applications and services.
💼 Career
Cloud engineers and administrators regularly create, list, and delete service account keys to maintain security and compliance.
Progress0 / 4 steps
1
Create a service account key
Write a command to create a service account key for the service account with email my-service-account@my-project.iam.gserviceaccount.com and save the key to a file named key.json.
GCP
Hint
Use the gcloud iam service-accounts keys create command with the --iam-account flag.
2
List all keys for the service account
Write a command to list all keys for the service account with email my-service-account@my-project.iam.gserviceaccount.com.
GCP
Hint
Use the gcloud iam service-accounts keys list command with the --iam-account flag.
3
Delete a specific service account key
Write a command to delete the service account key with ID 123abc456def789ghi for the service account with email my-service-account@my-project.iam.gserviceaccount.com.
GCP
Hint
Use the gcloud iam service-accounts keys delete command with the key ID and --iam-account flag.
4
Add a confirmation flag to the delete command
Modify the delete command to include the --quiet flag to avoid interactive confirmation prompts.
GCP
Hint
Add --quiet at the end of the delete command.
Practice
(1/5)
1. What is the main purpose of a service account key in Google Cloud?
easy
A. To manage billing information for Google Cloud projects
B. To store user passwords for Google Cloud accounts
C. To allow programs to securely access Google Cloud resources
D. To create virtual machines automatically
Solution
Step 1: Understand service account keys
Service account keys are used by programs, not humans, to access Google Cloud securely.
Step 2: Identify the correct purpose
They provide credentials for applications to authenticate and interact with cloud services.
Final Answer:
To allow programs to securely access Google Cloud resources -> Option C
Quick Check:
Service account keys = secure program access [OK]
Hint: Keys let programs access cloud securely, not users [OK]
Common Mistakes:
Confusing keys with user passwords
Thinking keys manage billing
Believing keys create virtual machines
2. Which gcloud command correctly creates a new service account key for the account my-service-account@my-project.iam.gserviceaccount.com?
easy
A. gcloud iam service-accounts keys create key.json --iam-account=my-service-account@my-project.iam.gserviceaccount.com
B. gcloud iam service-accounts create key.json --account=my-service-account@my-project.iam.gserviceaccount.com
C. gcloud service-accounts keys create key.json --account=my-service-account@my-project.iam.gserviceaccount.com
D. gcloud iam keys create key.json --iam-account=my-service-account@my-project.iam.gserviceaccount.com
Solution
Step 1: Identify correct gcloud command syntax
The correct command to create a key is gcloud iam service-accounts keys create with the --iam-account flag.
Step 2: Match the command with the options
gcloud iam service-accounts keys create key.json --iam-account=my-service-account@my-project.iam.gserviceaccount.com matches the correct syntax exactly.
Final Answer:
gcloud iam service-accounts keys create key.json --iam-account=my-service-account@my-project.iam.gserviceaccount.com -> Option A