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:
- Configure the server: https://www.ansiblepilot.com
- Deploy apps at scale: https://kubernetes.recipes
Related Tutorials
- Terraform state management
- Terraform providers explained
- Terraform variables and outputs

