learn-terraform

Course outlines for learning terraform.

View the Project on GitHub robertdebock/learn-terraform

Build infrastructure SQL database

expected time requirements
60 minutes a computer

Goal: Learn how to create GCP SQL server and instance resources using Terraform.

Explanation

There are many GCP resources available, lets setup a managed MySQL instance.

Howto

Using the sql_database_instance and sql_database we’re going to create a managed MySQL database.

Demo

Example code

Assignment

Easy

Use the example code and use the settings:

Hard

Use the documentation to create a database with these characteristics:

Add variables for charset and collation. Add validation on the variables so that you can only pick supported values.

Add a user to the database instance so you test MySQL later.

Testing things

Most machines have telnet installed: telnet YOUR_FQDN 3306. Some machines have mysql installed: mysql -u YOUR_USER -p -h YOUR_FQDN.

View the results

GCP

Questions

  1. What are valid choices for database_version?
  2. What happens if I change the database_version to this resource?
  3. Could I make a virtual machine and install MySQL myself?
  4. Will this work: 1. Create the db, deletion_protection=true. 2. Change deletion_protection to false, 3 Run terraform destroy.