📖 Scenario: You are working for a small online store that wants to keep its customer and order data safe and easy to manage. You decide to use a managed database service on Google Cloud Platform (GCP) to help with this.
🎯 Goal: Create a simple configuration for a managed database instance on GCP. This will help the store keep data safe, backed up, and easy to access without needing to manage the database server yourself.
📋 What You'll Learn
Create a variable called instance_name with the exact value store-db-instance
Create a variable called database_version with the exact value POSTGRES_14
Create a variable called tier with the exact value db-f1-micro
Create a variable called region with the exact value us-central1
Create a configuration dictionary called db_config that includes the instance name, database version, tier, and region
Add a final key backup_enabled set to True in db_config
💡 Why This Matters
🌍 Real World
Managed databases let businesses avoid the hard work of running database servers. They handle backups, updates, and scaling automatically.
💼 Career
Cloud engineers and developers often configure managed databases to ensure applications run smoothly without manual database management.
Progress0 / 4 steps
1
Create initial variables for the managed database
Create a variable called instance_name and set it to "store-db-instance". Then create a variable called database_version and set it to "POSTGRES_14".
GCP
Hint
Use simple assignment to create the variables with the exact names and values.
2
Add configuration variables for tier and region
Create a variable called tier and set it to "db-f1-micro". Also create a variable called region and set it to "us-central1".
GCP
Hint
Use simple assignment again for these two new variables.
3
Create the database configuration dictionary
Create a dictionary called db_config that includes the keys "instance_name", "database_version", "tier", and "region". Use the variables you created earlier as the values for these keys.
GCP
Hint
Use a dictionary with keys as strings and values as the variables you defined.
4
Enable backups in the database configuration
Add a key called backup_enabled with the value True to the db_config dictionary.
GCP
Hint
Add the new key and value inside the existing dictionary.
Practice
(1/5)
1. Why do many companies prefer managed databases over self-managed databases in the cloud?
easy
A. Because managed databases always cost less than self-managed ones
B. Because managed databases require manual hardware setup
C. Because managed databases do not support automatic failover
D. Because managed databases handle backups, updates, and scaling automatically
Solution
Step 1: Understand managed database features
Managed databases provide automatic backups, updates, and scaling without user intervention.
Step 2: Compare with self-managed databases
Self-managed databases require manual setup and maintenance, which is more complex and error-prone.
Final Answer:
Because managed databases handle backups, updates, and scaling automatically -> Option D
Quick Check:
Managed databases automate maintenance = A [OK]
Hint: Managed means automatic maintenance and scaling [OK]
Common Mistakes:
Thinking managed databases need manual hardware setup
Assuming managed databases lack failover support
Believing managed databases always cost less
2. Which of the following is the correct way to create a managed Cloud SQL instance using gcloud CLI?
easy
A. gcloud sql instances create my-instance --tier=db-f1-micro --region=us-central1
B. gcloud sql create instance my-instance --size=small --zone=us-central1-a
C. gcloud sql instances new my-instance --machine=db-n1-standard-1
D. gcloud sql setup my-instance --type=managed --region=us-central1
Solution
Step 1: Identify correct gcloud command syntax
The correct command to create a Cloud SQL instance is 'gcloud sql instances create' with tier and region flags.
Step 2: Check each option for syntax correctness
gcloud sql instances create my-instance --tier=db-f1-micro --region=us-central1 matches the official syntax; others use incorrect verbs or flags.
Final Answer:
gcloud sql instances create my-instance --tier=db-f1-micro --region=us-central1 -> Option A
Quick Check:
Correct gcloud create syntax = B [OK]
Hint: Use 'gcloud sql instances create' to make managed instances [OK]
Common Mistakes:
Using 'create instance' instead of 'instances create'
Wrong flags like --size or --machine
Confusing region and zone flags
3. Consider this code snippet using Google Cloud SDK to create a managed database instance:
What will happen if you run this command twice with the same instance name?
medium
A. The second command will fail with an error about duplicate instance
B. The second command will update the existing instance
C. The second command will create a new instance with a suffix
D. The second command will delete the first instance and create a new one
Solution
Step 1: Understand instance naming rules in Cloud SQL
Instance names must be unique. Creating an instance with an existing name causes an error.
Step 2: Predict behavior on duplicate creation
Running the create command again with the same name results in a failure due to name conflict.
Final Answer:
The second command will fail with an error about duplicate instance -> Option A
Quick Check:
Duplicate instance name causes error = A [OK]
Hint: Duplicate instance names cause errors, not updates [OK]
Common Mistakes:
Assuming the instance updates automatically
Thinking a new instance with suffix is created
Believing the old instance is deleted automatically
4. You tried to create a managed Cloud SQL instance but got an error: "Invalid tier specified." What is the most likely cause?
medium
A. You did not enable the Cloud SQL API
B. You used a tier name that does not exist or is misspelled
C. You used a valid tier but invalid instance name
D. You forgot to specify the region
Solution
Step 1: Analyze the error message
The error "Invalid tier specified" indicates the tier value is incorrect or unrecognized.
Step 2: Identify common causes
Misspelling or using a non-existent tier causes this error, not missing region or API enablement.
Final Answer:
You used a tier name that does not exist or is misspelled -> Option B
Quick Check:
Invalid tier error means wrong tier name = D [OK]
Hint: Check tier spelling and availability first [OK]
Common Mistakes:
Assuming missing region causes tier error
Thinking API enablement causes tier error
Ignoring typo in tier name
5. You want to ensure your managed Cloud SQL database automatically recovers from hardware failures without manual intervention. Which feature should you enable?
hard
A. Read replicas for reporting only
B. Manual backups scheduled daily
C. High availability with automatic failover
D. Custom machine types for performance tuning
Solution
Step 1: Identify the feature for automatic recovery
High availability with automatic failover ensures the database switches to a standby instance if hardware fails.
Step 2: Evaluate other options
Manual backups do not provide automatic recovery; read replicas are for scaling reads; custom machines tune performance but not recovery.
Final Answer:
High availability with automatic failover -> Option C
Quick Check:
Automatic failover = automatic recovery [OK]
Hint: Enable automatic failover for no-downtime recovery [OK]
Common Mistakes:
Confusing backups with automatic failover
Using read replicas for failover
Thinking custom machines handle recovery
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.