DEV Community

Alex Spinov
Alex Spinov

Posted on

Terraform Has a Free Infrastructure as Code Tool — Define Cloud Resources With Declarative Config Files

Terraform Has a Free Infrastructure as Code Tool — Define Cloud Resources With Declarative Config Files

Clicking through AWS/GCP/Azure consoles is slow, error-prone, and impossible to reproduce. Terraform lets you define your entire infrastructure in code — version-controlled, reviewable, and repeatable.

Free (Open Source)

  • Terraform CLI — completely free and open-source
  • All providers — AWS, GCP, Azure, Cloudflare, Vercel, 3000+ more
  • State management — local or remote (S3, GCS, Terraform Cloud)
  • Terraform Cloud — free for up to 500 managed resources
  • Modules registry — thousands of pre-built modules

Quick Start: Deploy to AWS

# main.tf
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

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

# Create a VPC
resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
  tags = { Name = "production-vpc" }
}

# Create an EC2 instance
resource "aws_instance" "api" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.micro"
  subnet_id     = aws_subnet.public.id

  tags = { Name = "api-server" }
}

# Create an S3 bucket
resource "aws_s3_bucket" "data" {
  bucket = "my-app-data-bucket"
}

# Create an RDS database
resource "aws_db_instance" "postgres" {
  engine         = "postgres"
  engine_version = "15.4"
  instance_class = "db.t3.micro"
  allocated_storage = 20
  db_name        = "myapp"
  username       = "admin"
  password       = var.db_password
}
Enter fullscreen mode Exit fullscreen mode

Workflow

# Initialize providers
terraform init

# Preview changes
terraform plan
# Shows: 4 resources to create

# Apply changes
terraform apply
# Creates all resources in AWS

# Destroy everything
terraform destroy
# Removes all managed resources
Enter fullscreen mode Exit fullscreen mode

Variables and Outputs

# variables.tf
variable "environment" {
  default = "production"
}

variable "instance_count" {
  type    = number
  default = 2
}

# outputs.tf
output "api_url" {
  value = aws_lb.api.dns_name
}

output "database_endpoint" {
  value     = aws_db_instance.postgres.endpoint
  sensitive = true
}
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

Terraform is the industry standard for infrastructure as code. Free, open-source, and supports every major cloud provider. Your infrastructure becomes version-controlled, reviewable, and reproducible.


Need to monitor cloud infrastructure, track resource changes, or build automated deployment pipelines? I create custom solutions.

📧 Email me: spinov001@gmail.com
🔧 My tools: Apify Store

Top comments (0)