Holmes Stacks
Career · June 6, 2026

Terraform Basics for AWS Infrastructure as Code

In this video, you will learn how to manage your AWS infrastructure using Terraform to ensure consistent and repeatable cloud deployments.

What this guide covers

You will learn how to replace manual AWS console deployments with Terraform, defining your cloud infrastructure as code to enforce consistency and reduce errors.

When to use it

  • Deploying a new EC2 instance or other AWS resource repeatedly without manual clicks
  • Synchronizing infrastructure changes across a team without configuration drift
  • Troubleshooting intermittent production issues caused by undocumented manual changes
  • Transitioning from browser-based AWS setup to automated, auditable infrastructure

The move, step by step

  1. Install Terraform
    Download and install Terraform from terraform.io/downloads. Verify with:
terraform version
  1. Initialize your Terraform project
    Create a directory and inside it a file ending in .tf (e.g., main.tf). Run:
terraform init

This sets up backend and provider plugins.

  1. Write your resource block
    Define your AWS resource in HCL inside the .tf file. Example EC2 instance:
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}
  1. Configure AWS credentials
    Set your AWS credentials using environment variables or AWS CLI config to allow Terraform access (see Terraform AWS Provider docs).

  2. Plan your changes
    Preview what Terraform will do before applying:

terraform plan
  1. Apply your configuration
    Deploy resources as described in your .tf files:
terraform apply

Confirm with yes when prompted.

  1. Manage incremental changes
    Edit your .tf files to update infrastructure. Run terraform plan and terraform apply again to sync those changes automatically without manual console edits.

Example

Input file main.tf:

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

Run commands:

terraform init
terraform plan
terraform apply

Expected output snippet:

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

An EC2 instance is now created exactly as defined, replacing manual AWS console clicks.

Common mistakes

  • Mistake: Not running terraform init before apply → Fix: Always initialize the directory first to install necessary plugins.
  • Mistake: Changing infrastructure manually in AWS console after Terraform deploy → Fix: Avoid manual changes; always update .tf files instead.
  • Mistake: Omitting AWS credentials setup → Fix: Configure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or use AWS CLI profiles.
  • Mistake: Applying without review → Fix: Always run terraform plan to preview changes before applying.
  • Mistake: Using hardcoded AMI IDs without updates → Fix: Track regional AMI changes or use data sources to get latest AMIs.

Next step

Write a simple Terraform file defining a new S3 bucket or EC2 instance and deploy it using terraform init, terraform plan, and terraform apply. 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