Learn Terraform from scratch: Infrastructure as Code fundamentals, the core workflow, variables, state management and reusable modules with hands-on examples.
34 lessons in this tutorial
Learn what Terraform is, how Infrastructure as Code works, why it beats clicking through cloud consoles, and how Terraform compares to Ansible, CloudFormation and Pulumi.
Step-by-step guide to installing Terraform on macOS, Linux and Windows using the official HashiCorp package managers. Verify the install and run your first real Terraform configuration.
The four commands that power every Terraform project, init, plan, apply, and destroy. Learn the complete workflow loop used by every DevOps engineer managing infrastructure as code.
Learn exactly what terraform init does, downloading providers, setting up backends, creating the lock file, and how to use init flags like -upgrade and -reconfigure.
Master terraform plan, understand execution plan output symbols (+/-/~/+/-), save plan files, target specific resources, detect configuration drift, and use plan in CI/CD pipelines.
Learn terraform apply in depth, reviewing and confirming the plan, auto-approve for CI/CD, applying saved plan files, parallel execution, watching real-time output, and handling apply errors safely.
Learn terraform destroy, safely tearing down infrastructure, using -target for partial destroys, understanding the destroy plan, and when to use destroy vs decommission. Includes terraform fmt and validate.
Learn how Terraform input variables, local values, and output values work together to make infrastructure code reusable, readable, and easier to share across environments.
Learn Terraform input variables in depth, including variable blocks, types, defaults, validation rules, tfvars files, CLI flags, environment variables, and sensitive values.
Learn how Terraform local values work, when to use locals instead of variables or data sources, and how to simplify repetitive expressions in your infrastructure code.
Learn Terraform output values in depth, including output blocks, sensitive outputs, terraform output commands, module outputs, and CI/CD automation patterns.
Learn the big picture of Terraform state, remote backends, and state management commands so you can work safely with real infrastructure and collaborate with confidence.
Learn what Terraform state is, why the terraform.tfstate file exists, how it maps to real infrastructure, and why state security and locking matter in production.
Learn why Terraform remote backends matter, how to configure S3 with DynamoDB locking, when to use Terraform Cloud or GCS, and how to migrate state safely.
Learn the most important Terraform state and import commands, including terraform state list, show, mv, rm, import, and refresh-related workflows.
Learn the big picture of Terraform modules, how to use existing modules safely, and how to write your own reusable modules for cleaner infrastructure code.
Learn how to use Terraform modules from local paths and the Terraform Registry, pass inputs, pin versions, run terraform init, and consume module outputs.
Learn how to write reusable Terraform modules, structure them with main.tf, variables.tf, and outputs.tf, and publish or share modules across projects.
Learn how Terraform data sources read existing infrastructure, how data blocks work, how outputs are referenced, and when to use data sources instead of resources.
Get a quick overview of Terraform count and for_each so you can choose the right repetition pattern before learning each meta-argument in detail.
Learn how Terraform count works, how count.index is used, how to create conditional resources, how to reference counted resources, and when count is a good fit.
Learn how Terraform for_each works with maps, sets, and transformed collections, how to reference named instances, and when for_each is better than count.
Get a quick overview of Terraform expressions and built-in functions before diving into string operations and collection transformations.
Learn Terraform string interpolation, formatting, replacements, regex helpers, templatefile, conditionals, and other string-oriented expressions used in real infrastructure code.
Learn Terraform list, map, set, and type-conversion functions, plus for expressions and transformation patterns for dynamic infrastructure code.
Learn how Terraform dynamic blocks generate nested configuration, where they fit well, how to use them safely, and when they make code too complex.
Learn what Terraform workspaces are, how workspace commands work, how state is separated, and when workspaces are helpful or the wrong environment strategy.
Build a complete AWS project with Terraform by combining a custom VPC, a public EC2 web server, and an S3 bucket for static assets.
Build a custom AWS VPC with Terraform, including public and private subnets, an internet gateway, route tables, and a NAT gateway.
Continue the AWS Terraform project by launching an EC2 web server with a security group, key pair, user data, and Elastic IP.
Continue the AWS Terraform project by creating an S3 bucket for static assets with versioning, lifecycle rules, public-read policy, and object uploads.
Learn what Terraform provisioners are, how local-exec, remote-exec, file, connection blocks, and null_resource work, and why provisioners should be a last resort.
Build a GitLab CI/CD pipeline for Terraform with validate, plan, apply, and destroy stages, environment controls, remote state, and secure credentials handling.
Learn how to scan Terraform code with tfsec and Checkov, protect secrets in state, secure backends, and integrate IaC security checks into CI/CD.