0
0
GCPcloud~30 mins

Creating a Cloud SQL instance in GCP - Try It Yourself

Choose your learning style9 modes available
Creating a Cloud SQL instance
📖 Scenario: You are setting up a Cloud SQL instance on Google Cloud Platform to host a database for a small web application. This instance will store user data securely and allow the application to connect to it.
🎯 Goal: Build a Cloud SQL instance configuration using Terraform that creates a MySQL database instance with basic settings.
📋 What You'll Learn
Create a Terraform resource block for a Cloud SQL instance named my-sql-instance.
Set the database version to MYSQL_8_0.
Configure the instance with a db-f1-micro machine type.
Set the region to us-central1.
Enable automated backups.
💡 Why This Matters
🌍 Real World
Cloud SQL instances are used to host managed relational databases for applications, removing the need to manage database servers manually.
💼 Career
Knowing how to create and configure Cloud SQL instances is essential for cloud engineers and developers working with Google Cloud Platform to build scalable and reliable applications.
Progress0 / 4 steps
1
DATA SETUP: Define the Terraform provider
Write a Terraform block to configure the Google Cloud provider with the project ID my-gcp-project and region us-central1.
GCP
Need a hint?

Use the provider "google" block with project and region attributes.

2
CONFIGURATION: Define the Cloud SQL instance resource
Add a Terraform resource block named google_sql_database_instance with the name my-sql-instance and set the database version to MYSQL_8_0.
GCP
Need a hint?

Use resource "google_sql_database_instance" "my-sql-instance" and set name and database_version.

3
CORE LOGIC: Configure the instance settings
Inside the google_sql_database_instance resource, add an settings block that sets the tier to db-f1-micro and the location to us-central1.
GCP
Need a hint?

Use a settings block with tier and location inside the resource.

4
COMPLETION: Enable automated backups
Inside the settings block, add a backup_configuration block with enabled = true to enable automated backups.
GCP
Need a hint?

Add a backup_configuration block inside settings with enabled = true.