Holmes Stacks
Career · June 4, 2026

Terraform Basics for AWS Infrastructure as Code

In this video, you will learn how to use Terraform to define and deploy AWS cloud infrastructure as reliable, reusable code.

What this guide covers

After reading this, you’ll know how to define AWS infrastructure using Terraform configuration files, run Terraform commands to preview and provision your setup, and keep your environments consistent without clicking through the AWS Management Console.

When to use it

  • Setting up a new AWS environment reliably without manual console clicks
  • Reproducing or scaling existing infrastructure on AWS with the same configuration
  • Avoiding configuration drift caused by manual changes over time
  • Automating frequent infrastructure changes in a version-controlled way

The move, step by step

  1. Install Terraform: Download and install Terraform from https://www.terraform.io/downloads. Verify installation with terraform version.
  2. Create a working directory: Make a folder for your Terraform configs and navigate into it in your terminal.
  3. Write a resource block: Define AWS resources in a .tf file using HCL syntax. Example for EC2:
    resource "aws_instance" "web" {  
      ami           = "ami-123456"  
      instance_type = "t2.micro"  
    }  
  4. Initialize Terraform: Run terraform init to download AWS provider plugins and prepare your directory.
  5. Preview changes: Use terraform plan to see what Terraform will create or change without applying it yet.
  6. Apply your config: Run terraform apply to provision resources described in your config files. Confirm with yes when prompted.
  7. Check state: Terraform maintains state locally or remotely. This tracks your deployed infrastructure and enables consistent updates.
  8. Update safely: Change your .tf files to adjust infrastructure, then run terraform plan and terraform apply again to update AWS resources incrementally.

Example

Input config file (main.tf):

resource "aws_instance" "web" {  
  ami           = "ami-0c55b159cbfafe1f0"  # Amazon Linux 2 AMI (example)  
  instance_type = "t2.micro"  
}  

Commands:

terraform init  
terraform plan  
terraform apply  

Expected output snippet from terraform plan:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_instance.web will be created  
  + resource "aws_instance" "web" {  
      + ami           = "ami-0c55b159cbfafe1f0"  
      + instance_type = "t2.micro"  
      ...  
    }  

Common mistakes

  • Mistake: Skipping terraform init → Fix: Always initialize your working directory before planning or applying.
  • Mistake: Running terraform apply without review → Fix: Use terraform plan first to understand changes.
  • Mistake: Hardcoding AMI IDs without region context → Fix: Parameterize AMI or use data sources for portability (official Terraform docs).
  • Mistake: Manually changing AWS resources outside Terraform → Fix: Avoid drift by making all changes through Terraform, so state stays accurate.
  • Mistake: Not storing Terraform state remotely for team environments → Fix: Use remote state backends like S3 with locking to collaborate safely.

Next step

Create a simple Terraform file defining one AWS resource (an EC2 instance or S3 bucket), run terraform init and terraform plan today. Review the plan output. Then come back and try the next move from the video.

Your one action today

Pick the smallest version of this guide and try it in your tool of choice in the next 20 minutes.

Free download
Get the AI Career Starter Kit — 25 ChatGPT prompts + a 12-month plan
Click to get it →
Go deeper
AI Career Stack Starter Kit — $39
75 prompts + resume system + cloud roadmap + Notion template

Get the next AI/career guide in your inbox

One short, practical guide on AI tools, cloud, and the modern career stack. No fluff.

Related guides