1. Understanding Terraform

Terraform is an Infrastructure as Code (IaC) tool developed by HashiCorp.

Think of it as a universal remote control for cloud infrastructure. Instead of clicking buttons in the cloud console, you write code (in HCL – HashiCorp Configuration Language) to describe what you want, and Terraform makes it happen.

Why Terraform is Awesome


2. Key Terraform Concepts

Term Meaning
Provider The plugin that knows how to talk to your cloud (e.g., google, azurerm)
Resource A cloud thing you want to create (VM, network, firewall, etc.)
Variable A parameter you can set to reuse code
State Terraform’s record of what’s been created, so it knows what to change
Attribute Properties or configurations of the resources, often required to create or manage it

3. Visualizing What We’ll Build

We’ll create this exact setup in both GCP and Azure:

+-------------------+         +-------------------+
|      VPC           |         |    Virtual Network|
|  (Google Cloud)    |         |    (Azure)        |
+---------+----------+         +---------+---------+
          |                              |
    +-----+-----+                  +-----+-----+
    |  Subnet   |                  |  Subnet   |
    +-----+-----+                  +-----+-----+
          |                              |
    +-----+-----+                  +-----+-----+
    | Firewall  |                  | NSG Rule   |
    +-----+-----+                  +-----+-----+
          |                              |
    +-----+-----+                  +-----+-----+
    | Compute VM |                  | Virtual VM |
    +-----------+                  +------------+


4. Setting Up Terraform

Before creating resources:

  1. Install Terraform

    Download here