Paths/DevOps Engineer/Terraform / Init & Plan
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
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- 01
Create the project directory
One directory = one Terraform root module. Keep it isolated from everything else.
mkdir ~/infra - 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 - 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 - 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 - 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 - 06
Submit for validation
The validator checks main.tf declares the bucket and that init ran in this directory.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — terraform 1.7
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list