Holmes Stacks
Career · June 4, 2026

Terraform Basics for Cloud Automation and Infrastructure as Code

This video explains how to use Terraform to automate cloud infrastructure provisioning and ensure consistent, repeatable deployments.

What this guide covers

After reading this guide, you will be able to write, apply, and manage a basic Terraform configuration to automate AWS cloud infrastructure provisioning declaratively. You’ll move away from manual console clicks to consistent, versioned infrastructure as code.

When to use it

  • Setting up a new EC2 instance or other AWS resources repeatedly across environments
  • Preventing configuration drift caused by manual changes in cloud consoles
  • Version-controlling your cloud infrastructure definitions alongside application code
  • Auditing and reviewing infrastructure changes in code before deployment

The move, step by step

  1. Install Terraform: Download and install Terraform from https://terraform.io/downloads based on your OS. Verify with terraform version.
  2. Create a Terraform config file: Make a file named main.tf with a resource block:
    resource "aws_instance" "web" {
      ami           = "ami-12345678"
      instance_type = "t2.micro"
      tags = {
        Name = "ExampleInstance"
      }
    }
  3. Initialize Terraform: Run terraform init in your project directory to download the AWS provider and prepare your working folder.
  4. Plan the deployment: Run terraform plan to see what changes Terraform will make on AWS without applying them yet.
  5. Apply the changes: Run terraform apply to provision your EC2 instance as defined. Confirm with yes.
  6. Manage and update: Modify your main.tf file to change instance properties, then repeat terraform plan and terraform apply to update infrastructure.
  7. Version control your config files: Add your .tf files to git so that all infrastructure changes are tracked and auditable.
  8. Destroy test resources: When done testing, run terraform destroy to clean up resources created by Terraform.

Example

Input main.tf:

resource "aws_instance" "web" {
  ami           = "ami-12345678"
  instance_type = "t2.micro"
  tags = {
    Name = "ExampleInstance"
  }
}

Commands:

terraform init
terraform plan
terraform apply

Expected output snippet after terraform apply:

aws_instance.web: Creating...
aws_instance.web: Creation complete after 30s [id=i-0abcd1234efgh5678]

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

Common mistakes

  • Mistake: Using console clicks to change resources after applying Terraform → Fix: Always update .tf files and re-apply to prevent drift.
  • Mistake: Forgetting to run terraform init before commands → Fix: Run terraform init once per project directory before planning or applying.
  • Mistake: Hardcoding AMI IDs without confirming they exist in your AWS region → Fix: Verify AMI availability for your chosen region to avoid errors.
  • Mistake: Not committing Terraform files to version control → Fix: Use git or another VCS to track infrastructure changes alongside code.

Next step

Download Terraform and create your first main.tf file with the example EC2 resource block above. Then run terraform init, terraform plan, and terraform apply to deploy it on AWS. After that, 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