Terraform (Infrastructure as Code)
Provision multi-cloud infrastructure declaratively. Master HCL, state locks, reusable modules, workspaces, and CI/CD pipelines.
Curriculum & Notes
Click any title or "See Notes" to read concepts1Module 1: IaC Foundations & Workflow
7 lessonsLearn what Terraform is and how Infrastructure as Code works, why it beats clicking through consoles, and how it compares to Ansible and CloudFormation.
Install Terraform on macOS, Linux and Windows with the official package managers, verify the version, switch versions with tfenv and run your first project.
Understand the Terraform init, plan, apply and destroy loop: what each command does, how to read a plan and the mistakes that cause outages.
Learn what terraform init does: download providers, configure the backend, write the lock file, use -upgrade and -reconfigure and run it in CI/CD.
Read terraform plan symbols correctly, save a plan file with -out, target resources, detect drift and run plan in CI/CD without surprises on apply.
Use terraform apply safely: review the plan, apply a saved plan file, tune parallelism, use -auto-approve in CI/CD and recover from common apply errors.
Run terraform destroy safely: read the destroy plan, preview it first, remove single resources with -target, and keep code tidy with fmt and validate.
2Module 2: Variables, Outputs & Locals
7 lessonsSee how data flows through Terraform: input variables, locals and outputs, where each belongs, how variable precedence works and how to handle secrets safely.
Declare Terraform input variables with types, defaults and validation, then set them via tfvars files, CLI flags and environment variables, including secrets.
Learn how Terraform local values work, when to choose locals over input variables or data sources, and how a locals block removes repeated expressions.
Declare Terraform output values, mark them sensitive, read them with the terraform output command and JSON, expose module outputs and use them in CI/CD.
Understand why Terraform keeps state, what is inside it, how remote backends and locking make teamwork safe, and the state commands that rescue you.
Learn what Terraform state is, why terraform.tfstate exists, how it maps to real resources, and why drift, state security and locking matter.
Configure a Terraform remote backend on S3 with DynamoDB state locking, bootstrap it, compare Terraform Cloud and GCS, and migrate state safely.
3Module 3: State Management & Backends
7 lessonsUse the Terraform state commands with confidence: state list, show, mv and rm, plus terraform import and refresh, and when each is safe to run.
Learn what Terraform modules are, when to write one, how to design a clean interface, version and source them, and move resources in without recreating them.
Learn how to call Terraform modules with a module block from local paths or the Registry, pass inputs, pin versions, run init and use module outputs.
Learn how to write a reusable Terraform module: structure main.tf, variables.tf and outputs.tf, build an S3 bucket module and call it locally.
Learn how Terraform data sources read existing infrastructure, how the data block works, how to reference its attributes and when to use data over resource.
Choose between Terraform count and for_each: see why count's positional identity can destroy resources, when each is correct and how to migrate safely.
Learn how the Terraform count meta-argument works: use count.index, build conditional resources, reference counted resources and know when count fits.
4Module 4: Writing Reusable Modules
7 lessonsLearn how Terraform for_each works with sets, maps and objects, how each.key and each.value are used, how to reference instances and when it beats count.
Learn Terraform expressions: types, references, conditionals, for expressions, key function categories, try and can, and testing in terraform console.
Work with strings in Terraform: interpolation, format, case and whitespace helpers, replace and regex functions, templatefile and conditionals.
Learn Terraform collection functions such as concat, flatten, distinct and slice, plus map and set helpers and for expressions for dynamic code.
Learn Terraform dynamic blocks: generate repeated nested blocks from a collection, with security group and IAM policy examples and the limits to respect.
Learn how Terraform workspaces separate state, the workspace new, select and list commands, terraform.workspace in code, and when to avoid them.
Configure the Terraform AWS provider, authenticate without long-lived keys using assume role and OIDC, manage regions and accounts, and tag everything.
5Module 5: Advanced HCL & Production CI/CD
6 lessonsBuild a custom AWS VPC with Terraform: public and private subnets, an internet gateway, route tables and a NAT gateway, explained step by step.
Launch an EC2 web server with Terraform: add a security group, find the latest Ubuntu AMI, create a key pair, write user data and attach an Elastic IP.
Create an S3 bucket with Terraform: unique names with random_id, versioning, lifecycle rules, public access settings, a bucket policy and object uploads.
Learn how Terraform provisioners work: local-exec, remote-exec, file and connection blocks, null_resource, and why provisioners should be a last resort.
Build a Terraform pipeline in GitLab CI/CD with validate, plan, manual apply and destroy stages, GitLab-managed state and secure credential handling.
Secure Terraform code by scanning with tfsec and Checkov, protecting secrets in state, fixing common misconfigurations and adding checks to CI/CD.