0Pricing
DevOps Bootcamp · Lesson

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 — lesson 3 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.

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 init

Steps 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-approve

Quick 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.

Frequently asked questions

Is the “Your First Terraform Configuration” lesson free?

Yes — the full text of “Your First Terraform Configuration” 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 “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; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

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

  1. Introduction to IaC and Terraform
  2. Installing Terraform and CLI Basics
  3. Your First Terraform Configuration
  4. Understanding Terraform Plan and Apply
← Back to DevOps Bootcamp