Terraform Basics Simulator
Learn Terraform basics in an interactive browser lab. Read and edit the HCL config, run init, validate, plan, apply, and destroy, and watch state react to your edits. A free, hands-on way to learn infrastructure as code with no AWS account.
Category: DevOps
What You Will Learn
- What infrastructure as code (IaC) is and why teams use Terraform
- The HCL building blocks: provider, resource, variable, output, and state
- The core Terraform workflow: init, validate, plan, apply, and destroy
- How to read a plan: + create, ~ change in place, and - destroy
- How editing your config changes the plan against existing state
- Why you destroy throwaway environments to control cost
Topics covered: terraform, learn-terraform, terraform-basics, terraform-tutorial, iac, infrastructure-as-code, hcl, aws, terminal, devops, beginner, educational, interactive
// simulator
Terraform Basics Simulator
Learn Terraform basics in an interactive browser lab. Read and edit the HCL config, run init, validate, plan, apply, and destroy, and watch state react to your edits. A free, hands-on way to learn infrastructure as code with no AWS account.
Terraform Basics Lab
Learn Terraform by doing. Read and edit the HCL on the left, run init, plan, apply, and destroy in the terminal, and watch state change on the right. Edit the config and plan again to see Terraform detect the difference. Nothing is provisioned for real.
Initialize: Initialize the working directory so Terraform installs the AWS provider.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = var.region
}
resource "aws_security_group" "web" {
name = "web-sg"
description = "Allow HTTP and SSH"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = var.instance_type
vpc_security_group_ids = [aws_security_group.web.id]
tags = {
Name = "${var.project}-web"
}
}
resource "aws_s3_bucket" "assets" {
bucket = "${var.project}-assets"
}Welcome to the Terraform Basics Lab.
Type "help" for commands, or follow the current task. Start with terraform init.
No resources yet. Run terraform apply to create them.
Terraform basics, explained
Terraform is an infrastructure as code (IaC) tool. Instead of clicking through a cloud console, you describe the infrastructure you want in configuration files, and Terraform figures out how to create, change, or destroy it to match. This lab teaches that loop hands-on. Below is the background to go with it.
The building blocks (HCL)
- provider: the plugin Terraform uses to talk to a platform, such as AWS, Azure, or GCP.
- resource: a single piece of infrastructure, like an EC2 instance or an S3 bucket.
- variable: an input you can change without editing the main config, such as region or instance size.
- output: a value Terraform exposes after apply, like an instance IP, for you or other tools to read.
- state:Terraform's record of what it created, so it knows what to change next time.
The core workflow
- terraform init: download providers and prepare the directory. Run it first.
- terraform validate: check the config is syntactically valid.
- terraform plan: preview the changes. + create, ~ change, - destroy.
- terraform apply: make the changes and write them to state.
- terraform destroy: tear everything down so it stops costing money.
Try it in the lab
Run terraform init, then plan and apply to create the example resources. Then switch the config panel to edit mode, change instance_type in variables.tf, and run terraform plan again. Terraform shows a ~ in-place update because your config no longer matches state. Delete a resource block and plan shows a - destroy. That diff between desired and actual is the heart of how Terraform works.
Common beginner gotchas
- Always read the plan before you apply. The plan is your safety check.
- State is the source of truth. Never hand-edit it, and store it in a remote backend for teams.
- Some changes update in place; others force a replacement (shown as -/+ in a real plan).
- Keep secrets out of plaintext config and state. Use variables and a secrets manager.
- Run terraform destroy on throwaway environments so you do not pay for idle resources.
Browser-safe by design
This lab does not provision real infrastructure. It models a small AWS configuration (a security group, an EC2 instance, and an S3 bucket) in the browser so you can read and edit the HCL, run the full workflow, and see state change without an AWS account or any cost.
Try next
// simulator
Docker Terminal Simulator
Practice Docker commands in an interactive browser terminal. Learn images, containers, logs, exec, Dockerfile builds, volumes, networks, and Docker Compose with a live Docker daemon visualization.
// simulator
Kubernetes Terminal Simulator
Practice Kubernetes commands in an interactive browser terminal. Learn kubectl contexts, nodes, Pods, Deployments, Services, rollouts, logs, exec, events, ConfigMaps, and cleanup workflows with a live cluster visualization.
// simulator
Git Concepts Simulator
Practice Git in an interactive browser terminal with a visual repository model. Learn the working directory, staging area, local commits, branch pointers, remotes, fast-forward merges, fetch, and rebase.