Your First Terraform Configuration
Walk through creating a basic Terraform configuration file to declare and provision a simple cloud resource, demonstrating the core workflow.
Your First Terraform Configuration is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
Your First Terraform Config
Time to write your first real Terraform config — you'll create a .tf file, declare a provider and resource, and run the full init/plan/apply workflow.
Meet the .tf File
Terraform configs live in .tf files written in HCL. By convention your main one is main.tf, but any .tf filename works.
Declaring a Provider
A provider block tells Terraform what to talk to. We'll use the local provider here, which just manages files on your machine — a cloud-free start.
provider "local" {
# Configuration for the local provider
}Defining a Resource
A resource block declares an infrastructure component — a VM, database, or here a file. It pairs a resource type with a name you choose plus its arguments.
Our First Resource: local_file
Here's a local_file resource: when applied, Terraform writes a text file on your machine with the content and filename you give it.
resource "local_file" "example" {
content = "Hello, CoddyKit!"
filename = "hello.txt"
}Your Complete main.tf
Combine the provider and resource into one main.tf — and that's a complete config defining your first piece of infrastructure.
provider "local" {}
resource "local_file" "example" {
content = "Hello, CoddyKit!"
filename = "hello.txt"
}Recall the Core Workflow
Now apply the core workflow to bring this file to life: init prepares the directory, plan previews, and apply makes the change.
Step 1: terraform init
Start with terraform init in the same folder as main.tf — it downloads the local provider plugin you need.
terraform initSteps 2 & 3: plan & apply
Next run terraform plan to see the changes, then apply to execute. Add --auto-approve to skip the confirmation prompt.
terraform plan
terraform apply --auto-approveQuick Check: Workflow
You've just deployed your first resource! Now, let's test your understanding of the core Terraform workflow.
Recap: First Deployment!
You shipped your first resource! Recap: a .tf file in HCL, a provider block, a resource block, and the init/plan/apply workflow that provisions it.
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Your First Terraform Configuration” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Your First Terraform Configuration”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Your First Terraform Configuration”?
Walk through creating a basic Terraform configuration file to declare and provision a simple cloud resource, demonstrating the core workflow. 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, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.
How long does the “Your First Terraform Configuration” 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