Course Details
A 3-day course, 6 hours per day (18 hours in total), delivered as lectures with hands-on cloud labs for every topic. Intermediate level. Learners take home a lab guide, complete sample code for every lab, reusable modules and a best-practice checklist. Note: learners create real resources in a test cloud account and should run terraform destroy after each lab to avoid ongoing charges.
Day 1: Terraform Fundamentals and State
Section 1: Infrastructure as Code Concepts and Setup
- The problems with manual provisioning and the benefits of infrastructure as code
- How Terraform works: declarative configuration, providers, plan and apply, compared with other tools
- Installing the Terraform CLI and configuring cloud credentials securely
- Lab: install Terraform and create your first cloud resource from code
Section 2: The HCL Language and Code Structure
- The .tf file structure and core blocks: terraform, provider, resource and data
- Data types, expressions, conditionals and commonly used functions
- Referencing resources and controlling creation order through dependencies
- Lab: write code that creates a network and a server that reference each other
Section 3: Providers and Resource Management
- Using providers and pinning versions with version constraints
- The resource lifecycle: create, update, replace and destroy, and reading plan output
- Using data sources to reference resources that already exist
- Lab: change infrastructure and read the plan carefully before every apply
Section 4: State Management
- What state is, why it matters and the risk when state is lost or edited incorrectly
- State commands: show, list, mv and rm, and when to use each
- Protecting secrets in state and never committing state to Git
- Lab: explore the state file and practise moving resources within state
Day 2: Variables, Modules and Teamwork
Section 5: Variables, Outputs and Configuration
- Declaring variables, types, defaults and validation rules
- Passing values through tfvars files, environment variables and the command line
- Using outputs to expose values and locals to reduce repetition
- Lab: refactor hardcoded configuration into variables and outputs
Section 6: Reusable Modules
- Module concepts and designing for reuse across projects
- Writing your own modules and consuming modules from the Terraform Registry
- Structuring a project so it stays readable and maintainable
- Lab: split the code into a module and reuse it across two environments
Section 7: Multiple Environments (Dev, Staging, Prod)
- Separating environments with workspaces versus directory structure
- Managing environment-specific values safely
- Naming and tagging conventions that make cost tracking possible
- Lab: build dev and prod environments from one codebase
Section 8: Remote State and Team Collaboration
- Storing state in a remote backend and why teams need it
- State locking to prevent concurrent changes from corrupting state
- Team workflow: branches, pull requests and reviewing plan output before apply
- Lab: migrate state to a remote backend and test locking with concurrent runs
Day 3: Existing Resources, Security and CI/CD
Section 9: Bringing Existing Resources Under Management
- Using terraform import to manage resources that were created manually
- Handling configuration drift when reality and code diverge
- Migrating legacy systems to Terraform gradually without service disruption
- Lab: import a manually created resource and align the code with reality
Section 10: Security and Secret Management
- Handling secrets: never storing passwords or keys in code or Git
- Using cloud secret management services together with Terraform
- Granting the Terraform execution account least-privilege permissions
- Scanning infrastructure code for insecure configuration
Section 11: CI/CD for Terraform
- Building a pipeline that runs fmt, validate and plan automatically on pull requests
- Gating apply behind approval before it touches production
- Keeping plan output as evidence and rolling back when something goes wrong
- Lab: create a pipeline that checks code and runs plan automatically on a Git repository
Section 12: Capstone and Best Practices
- Capstone: design and build a complete infrastructure stack with Terraform from network to application
- Best practices for writing and maintaining infrastructure code long term
- Moving on to Ansible, Kubernetes and other DevOps tooling
- Workshop: present the stack you built and review the code together