Installing Terraform and CLI Basics
Learn to install Terraform on your local machine and become familiar with essential command-line interface (CLI) commands like `init`, `plan`, and `apply`.
Installing Terraform and CLI Basics is a free DevOps Bootcamp lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Welcome to Terraform CLI!
Terraform runs through its command-line interface — you type commands in a terminal to manage infrastructure. Let's get it installed and learn the basics.
Getting Terraform Ready
Installing Terraform is three moves: download the binary for your OS, extract it, then add it to your PATH so your shell can find it by name.
Installation Methods
On macOS or Linux, reach for a package manager like Homebrew; on Windows use Chocolatey or add the binary to PATH manually. Always grab it from HashiCorp's official releases.
Verify Your Setup
After installing, confirm it worked by checking the version in your terminal.
terraform -vUnderstanding `terraform init`
terraform init prepares a working directory — it downloads the provider plugins Terraform needs and sets up the state backend. Think of it as project setup.
Your First `init`
Drop a simple main.tf in a folder, then run terraform init there. This config uses a null_resource, a harmless placeholder perfect for learning.
terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "~> 3.0"
}
}
}
resource "null_resource" "example" {
# This resource does nothing, useful for testing
}The `terraform plan` Command
terraform plan generates an execution plan — a dry run showing exactly what will be created, changed, or destroyed, with nothing actually touched yet.
Reviewing Your Plan
Running plan against our main.tf reports that one resource will be added, like this.
Terraform will perform the following actions:
# null_resource.example will be created
+ resource "null_resource" "example" {
+ id = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
The `terraform apply` Command
terraform apply executes the plan — actually creating, updating, or destroying resources. It shows the plan once more and asks you to confirm first.
Applying Your Infrastructure
Type terraform apply, confirm with 'yes', and Terraform provisions the resources. The output confirms our null_resource was created.
null_resource.example: Creating...
null_resource.example: Creation complete after 0s [id=...]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
CLI Command Check
Which Terraform command is used to preview the changes that will be made to your infrastructure without actually applying them?
Recap: CLI Essentials
Recap: you can install and verify Terraform, then run init to set up, plan to preview, and apply to execute. Next: defining resources in depth.
Frequently asked questions
Is the “Installing Terraform and CLI Basics” lesson free?
Yes — the full text of “Installing Terraform and CLI Basics” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Installing Terraform and CLI Basics”?
Learn to install Terraform on your local machine and become familiar with essential command-line interface (CLI) commands like `init`, `plan`, and `apply`. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Installing Terraform and CLI Basics” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to IaC and Terraform
- Installing Terraform and CLI Basics
- Your First Terraform Configuration
- Understanding Terraform Plan and Apply