You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp that allows you to define, provision, and manage cloud infrastructure using a declarative configuration language known as HCL (HashiCorp Configuration Language).
Instead of manually creating AWS resources (like EC2 instances, S3 buckets, Lambda functions, etc.) through the AWS console, Terraform allows you to write .tf files and version control your infrastructure just like application code.
β Key Features:
Cloud-Agnostic: Supports AWS, Azure, GCP, Oracle, and more.
Declarative Language: Define desired state; Terraform figures out how to achieve it.
Dependency Management: Handles dependencies between resources automatically.
Modular: Promote reuse with modules.
State Management: Keeps track of infrastructure in a terraform.tfstate file.
π Terraform vs. AWS SAM vs. Serverless Framework
Feature / Tool
Terraform
AWS SAM
Serverless Framework
Type
Infrastructure as Code (IaC)
Serverless-specific IaC
Serverless Framework (multi-cloud, plugin-rich)
Language
HCL (Hashicorp Configuration Language)
YAML
YAML + JavaScript plugins
Scope
Broad: EC2, S3, RDS, Lambda, VPC, etc.
Narrow: AWS Lambda & related services
Serverless focus (multi-cloud)
State Management
Yes (remote or local state)
No built-in; relies on CloudFormation
No state file (uses CloudFormation for AWS)
Multi-cloud Support
Yes
No
Yes (AWS, Azure, GCP)
CLI Experience
terraform apply, plan, etc.
sam build, sam deploy
sls deploy, sls invoke
Extensibility
Modules & providers
Limited
Plugin system
π§ Terraform Example: Creating an AWS S3 Bucket and Lambda