Learn Everything

Paths/DevOps Engineer/Terraform / Init & Plan

Guided Taskbeginnerterraform 1.7Ask AI

Write Your First Configuration

Terraform turns .tf files into real infrastructure. Write a configuration that declares an S3 bucket, initialize the provider and generate a plan — the read-only preview every change should start with.

Validator

⏱ 0:00

IDLE — checks run live as you type commands; submit when done

01Requirements

live checks
  • Directory ~/infra contains main.tf with an aws_s3_bucket resource○
  • terraform init has been run in ~/infra○
  • A plan was generated successfully○

02Walkthrough

6 steps
  1. 01

    Create the project directory

    One directory = one Terraform root module. Keep it isolated from everything else.

    mkdir ~/infra
  2. 02

    Enter it and declare the resource

    The next command writes main.tf. resource "aws_s3_bucket" "demo" is HCL: TYPE NAME. The block body is empty here — defaults only.

    cd ~/infra
  3. 03

    Write main.tf

    echo 'resource "aws_s3_bucket" "demo" {}' > main.tf — this is your entire infrastructure definition. Terraform figures out the rest.

    echo 'resource "aws_s3_bucket" "demo" {}' > main.tf
  4. 04

    Initialize

    terraform init downloads the provider plugins your configuration needs (hashicorp/aws here) and sets up the backend. Run it once per module, and after every provider change.

    terraform init
  5. 05

    Plan

    terraform plan compares the code with reality and prints the diff: + means will be created. Read the plan before every apply — it's your last line of defense.

    terraform plan
  6. 06

    Submit for validation

    The validator checks main.tf declares the bucket and that init ran in this directory.

03Stuck?

0 of 3 revealed

Take a hint without losing the lab — each one points at the thing to look at, not at the answer.

04AI Tutor

guides, never solves

Tell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?

04Notebook

saved locally in this browser

learner@lab — terraform 1.7

↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list