Infrastructure as Code with Terraform
Introduction
This hack is intended as an introduction to provisioning GCP resources using Terraform. We’ll start with the basics of Infrastructure as Code (IaC) and help you automate the process of infrastructure provisioning.
Warning As of June 2024 Cloud Source Repositories is end of sale. However, any organization that has created at least one CSR repository in the past, will still have access to existing repositories and will be able to create new ones. If you’re running this in a Qwiklabs environment you’re good to go, but if you’re running this in your own environment, please verify that you have access to Cloud Source Repositories in your organization.
Learning Objectives
In this hack you will be exploring the following tasks
- Setting up a version control system to hold your assets
- Setting up a Terraform backend
- Provisioning a few basic resources on GCP with Terraform
- Automating the process using Cloud Build
Challenges
- Challenge 1: Bootstrapping
- Terraform backend & version control
- Challenge 2: Your very first provisioning
- Let’s start with networking
- Challenge 3: Open the gates!
- Opening the Firewall ports
- Challenge 4: Hello HTTP server
- NGINX on a Linux VM
- Challenge 5: Automation
- Enable GitOps by running Terraform through Cloud Build
Prerequisites
- Your own GCP project with Owner IAM role
- Basic knowledge of GCP
- Knowledge of Git & Terraform
- Access to an environment to install & run CLI commands (e.g. Cloud Shell)
Contributors
- Murat Eken
- Mohammed Fawzi