Welcome! This repository is a hands-on guide for learning Infrastructure as Code (IaC) on Microsoft Azure using Terraform. It is structured for beginners and self-learners, with step-by-step instructions and practical demos.
-
Install Tools
Install Terraform, Azure CLI, VS Code, and Git on macOS. -
Terraform Command Basics
Learn and practice core Terraform commands (init,validate,plan,apply,destroy). -
Terraform Language Basics
Understand HCL syntax, blocks, arguments, and meta-arguments. -
Resource Syntax, Behavior & State
Learn about resource block syntax, lifecycle behavior, and Terraform state management. -
Azure VNET, Subnets & NSG (Hands-On)
Build a multi-tier Azure Virtual Network with subnets and NSGs using advanced Terraform concepts. -
Azure Linux VM (Hands-On)
Build an Azure Linux Virtual Machine on top of the networking created in the previous section.
- Clone this repository:
git clone <your-repo-url> cd az-terraform
- Follow the Install Tools guide to set up your environment.
- Work through each section in order, starting with Terraform Command Basics.
Terraform enables you to define, provision, and manage Azure infrastructure using code. This approach brings repeatability, version control, and collaboration to cloud resource management.
Terraform treats all .tf files in a directory as a single configuration. When you run commands like terraform init, plan, or apply, Terraform:
- Loads all .tf files in the working directory (order does not matter).
- Merges the configuration into a single in-memory graph, combining resources, variables, locals, outputs, and providers.
- Resolves dependencies between resources automatically (using references,
depends_on, etc.). - Executes the plan based on the dependency graph, ensuring resources are created, updated, or destroyed in the correct order.
This modular approach lets you split your configuration into logical files (e.g., one for each resource type or feature), making your code organized and maintainable. Terraform handles the orchestration behind the scenes!
This repository uses a numbered Terraform file naming convention to make the learning flow easier to follow across sections.
Example patterns:
c5-01-versions.tfc5-02-generic-input-variables.tfc6-01-web-linuxvm-input-variables.tfc6-05-web-linuxvm.tf
How to read the naming pattern:
c5means the file belongs to section 05.c6means the file belongs to section 06.- The two-digit number such as
01,02, or05represents the recommended reading and build sequence within that section. - The remaining part of the filename describes the purpose of the file.
Why this helps:
- It keeps the file order easy to understand for beginners.
- It makes it clear which files were carried forward from earlier sections.
- It helps when a later section reuses and extends code from a previous hands-on module.
Recommended approach when reusing code from earlier sections:
- Keep files copied forward from section 05 with the
c5-xx-...prefix. - Add new files introduced in section 06 with the
c6-xx-...prefix. - Continue the same pattern in future sections so the module history stays obvious.
Important: Terraform does not execute files based on filename order. Terraform loads all .tf files in a directory as one configuration and determines execution order from the dependency graph. The filename convention is for readability, teaching flow, and maintainability.
- This repo is a work in progress. Advanced topics (modules, variables, outputs, etc.) will be added soon.
- Each module may include a
tf-manifestsfolder containing Azure resource Terraform code. Use these as hands-on exercises to practice and reinforce your learning. - Feedback and suggestions are welcome!
Happy Learning! π