LEARNING PATH › Terraform Fundamentals
LEVEL 01 / BEGINNER~60–90 MIN
YOUR FIRST INFRASTRUCTURE DEPLOYMENT

Build your first
cloud server.

Use Terraform to provision an Ubuntu virtual machine on Amazon Web Services. Learn the workflow, understand each file, review the plan, and clean up the resources when you're done.

TERRAFORM
.tf files
AWS provider
terraform plan
Ubuntu EC2
01Hands-on project
6Learning milestones
0 → 1Your first EC2 server
01 / UNDERSTAND THE BUILD

What are we creating?

A simple Ubuntu EC2 instance in the default VPC, with an inbound HTTP rule. Terraform describes the infrastructure; AWS hosts it.

Architecture
Your computerTerraform CLI + .tf files
→
AWS providerAuthenticated API calls
→
Amazon Web ServicesDefault VPC · Security group
↓
Ubuntu EC2 instancePublic IP · HTTP access
Conceptual flow — the security group permits HTTP (port 80); this lab does not open SSH to the internet.
COMPUTE

Ubuntu EC2

A virtual server launched using an Ubuntu AMI and a configurable instance type.

NETWORK

Default VPC

Uses the account's default VPC and its default subnets to keep the first lab smaller.

ACCESS

HTTP rule

Allows inbound TCP port 80 from the internet. A web server must still be installed separately to serve a page.

02 / GET READY

Before you start

Complete these checks before running Terraform. You need access to an AWS account and a terminal on your computer.

01

Install Terraform CLI

Use the official installer for your operating system, then verify with terraform version.

02

Install and configure AWS CLI

Configure a named profile with credentials or a role. Never paste access keys into Terraform files.

03

Confirm your AWS identity and region

Run aws sts get-caller-identity --profile terraform-lab and confirm the intended account.

04

Create a dedicated project folder

Keep the Terraform configuration in one folder and open it in your terminal or VS Code.

05

Check cost and permissions

Use a sandbox account, confirm the selected instance type and understand AWS charges before applying.

06

Review the lab safety notes

Do not commit state, plan files, credentials or other sensitive values to a public repository.

Official setup: Terraform installation · AWS CLI installation

03 / READ THE CONFIGURATION

Meet your Terraform files

Each file has one clear responsibility. Select a tab, read the explanation, and copy the configuration into your project.

4 files
terraform/versions.tf

Provider and version requirements

This file declares the required Terraform version and AWS provider source. The lock file created by initialization records the selected provider build.

The example uses a default VPC lookup. It will fail in an AWS account or region where no default VPC exists. Confirm your account setup before running the lab.
04 / RUN THE WORKFLOW

Command walkthrough

Run these commands in your local terminal from the Terraform project folder. The simulator below explains the expected purpose; it does not run commands on your machine.

The safe Terraform lifecycle

01

Initialize

Download required provider plugins.

02

Format & validate

Check style and configuration structure.

03

Plan

Review proposed changes before approval.

04

Apply

Create the infrastructure after review.

Try the command simulator

Choose a command to see what it does and what to look for in the output.

local terminal · simulation
$ Select a command below to begin.
This is a guided simulation, not a real shell.
Important: review every line of terraform plan. Applying creates billable AWS resources. Do not approve a plan if the account, region, instance type, network or proposed changes are unexpected.
05 / FINISH THE LAB RESPONSIBLY

Verify, then clean up

A successful apply is not the end. Confirm what was created, understand the outputs, and destroy the disposable resources when finished.

VERIFY

Check the deployment

  • Review the EC2 instance in the AWS console.
  • Confirm its state is running and the region is correct.
  • Use terraform output to inspect the instance ID and public IP.
  • Remember: an EC2 instance alone does not install or start a web server.
CLEAN UP

Destroy the lab resources

First preview the destroy operation, inspect the proposed deletions, and only then run the destroy command.

cleanup commands
terraform plan -destroy
terraform destroy
Cleanup reminder: confirm the correct workspace and state before destroying anything. Terraform only knows about resources tracked by the selected state.
06 / CHECK YOUR UNDERSTANDING

Quick knowledge check

Answer all three questions to test the core ideas from this lab.

1. What does terraform plan do?

2. Where should AWS access keys be stored?

3. Why should you run terraform destroy for a disposable lab?