Skip to main content
Terraform on AWS: A Complete Beginner's Guide

Terraform on AWS: A Complete Beginner's Guide

Key Takeaway

A beginner-friendly Terraform AWS guide with provider setup, an S3 bucket example, and best practices for safe deployments.

Table of Contents

Introduction

Terraform on AWS lets you define infrastructure as code (IaC) so you can create, update, and destroy resources safely and repeatably. This guide walks you through a complete “hello world” on AWS with Terraform, including provider setup, a minimal configuration, and clean-up steps.

Prerequisites

  • An AWS account.
  • AWS CLI configured with credentials (aws configure).
  • Terraform installed (terraform version).

Step 1: Create a Working Folder

Create a new folder and add a main.tf file.

terraform {
  required_version = ">= 1.5.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

Step 2: Create Your First AWS Resource (S3 Bucket)

Add a simple S3 bucket definition.

resource "aws_s3_bucket" "demo" {
  bucket = "terraformpilot-demo-bucket-12345"
}

Tip: Use a globally unique bucket name.

Step 3: Initialize and Deploy

Run the standard Terraform workflow:

terraform init
terraform plan
terraform apply

Step 4: Inspect the State

Terraform tracks your infrastructure in terraform.tfstate. You can list managed resources with:

terraform state list

Step 5: Destroy When Finished

Clean up to avoid charges:

terraform destroy

Best Practices for Beginners

  • Keep provider versions pinned.
  • Use a dedicated workspace for each environment (dev/stage/prod).
  • Move state to a remote backend (S3 + DynamoDB) as soon as you collaborate.

Next Steps in the DevOps Chain

Once the server exists, you can configure it with Ansible and then orchestrate workloads with Kubernetes:

  • Terraform state management
  • Terraform providers explained
  • Terraform variables and outputs
🚀

Level Up Your Terraform Skills

Hands-on courses, books, and resources from Luca Berton

Luca Berton
Written by

Luca Berton

DevOps Engineer, AWS Partner, Terraform expert, and author. Creator of Ansible Pilot, Terraform Pilot, and CopyPasteLearn.