Learn Terraform
Describe cloud infrastructure in code and build it repeatably.
Free to start. Built from a single prompt. No credit card.
Terraform is an infrastructure-as-code tool from HashiCorp that lets you describe servers, networks, databases and DNS records in configuration files and then create them with one command. You write HashiCorp Configuration Language (HCL) declaring the end state you want, and providers translate it into API calls for AWS, Azure, Google Cloud, Cloudflare and many other services. Terraform tracks what exists in a state file and shows a plan of changes before applying them. OpenTofu is a community fork with the same workflow. Learnr builds a personalized Terraform course and teaches it through short, practical lessons.
How to learn Terraform, step by step
- Understand the cloud resources first. Terraform automates infrastructure you should already understand. Create a virtual machine, a storage bucket and a network by hand in one cloud console so you know what the code is describing.
- Run the core workflow on something tiny. Install Terraform, write a main.tf with one provider and one resource, then run terraform init, plan and apply. Read every line of the plan, then clean up with terraform destroy to avoid charges.
- Parameterize with variables and outputs. Move hardcoded values into variables with types and defaults, expose useful values as outputs and use data sources to look up existing resources. Run terraform fmt and validate on every change.
- Learn how state works and store it remotely. Open the state file to see what Terraform tracks, then move it to a remote backend with locking, such as an S3 bucket. Never edit state by hand or commit it to Git, since it can contain secrets.
- Write modules for repeated patterns. Package a standard network or web server setup as a module with inputs and outputs, then reuse it for dev and production. Pin provider and module versions so builds stay reproducible.
- Run Terraform from a pipeline. Have pull requests run terraform plan and post the output for review, with apply after merge. Use short Learnr lessons to keep HCL syntax and state commands fresh between projects.
What you'll learn
- Run the init, plan, apply and destroy workflow confidently
- Write HCL resources, variables, outputs and data sources
- Explain and protect Terraform state with remote backends
- Build reusable modules and use them across environments
- Review plans to catch destructive changes before they happen
What's inside your Terraform course
A sample path Learnr builds for Terraform. Your real course adapts to your goal and level.
- 1. Infrastructure as code and installing Terraform
- 2. Providers, resources and the core workflow
- 3. Variables, outputs, locals and data sources
- 4. State, remote backends and locking
- 5. Modules and multiple environments
- 6. Terraform in CI/CD, testing and team practices
How long does it take to learn Terraform?
With some cloud experience, the basics take 1 to 3 weeks at 5 hours a week. Comfortable use of modules, remote state and team workflows usually takes 2 to 3 months. Cloud knowledge, not HCL, is usually the slower part.
What you need before you start
Familiarity with one cloud provider such as AWS, plus command-line and Git basics. Some understanding of networking ideas like subnets and security groups helps a lot.
Common mistakes to avoid
- Running apply without reading the plan, then deleting a database. Look for destroy and replace actions in every plan before confirming.
- Keeping state on a laptop or in Git, which causes conflicts and leaks secrets. Use a remote backend with locking from the first team project.
- Changing resources by hand in the console after Terraform created them, causing drift. Make every change through code.
How Learnr builds your course
Type your topic
Tell Learnr you want to learn Terraform, or get as specific as you like.
Get a personalized course
Learnr instantly builds a full Terraform course tailored to your goal and skill level.
Learn and level up
Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.
Terraform questions, answered
Terraform or the cloud provider tools like CloudFormation?
CloudFormation only manages AWS, while Terraform works across many providers with one workflow. If your work is entirely on AWS, either is reasonable; Terraform skills transfer more widely.
What is the difference between Terraform and OpenTofu?
OpenTofu is an open-source fork created after HashiCorp changed Terraform's license in 2023. Configuration and commands are largely compatible, so learning one teaches you the other.
Explore more courses
More programming and tech courses
- Learn Microservices
- Learn Web Accessibility
- Learn Ethical Hacking
- Learn Assembly Language
- Learn Embedded Systems
- Learn Arduino
- Learn Raspberry Pi
- Learn MATLAB
See all programming and tech courses
Ready to learn Terraform?
Start your free, personalized Terraform course in seconds. .