Getting Started with Terraform
0 views
Getting Started with Terraform
Terraform by HashiCorp lets you define and manage infrastructure as code (IaC) using a declarative config language.
Why Terraform?
- Multi-cloud: Same workflow for AWS, GCP, Azure, and many providers.
- State: Tracks what exists and only applies changes.
- Plan:
terraform planshows what will change before you apply.
Basic example (local file)
terraform {
required_providers {
local = { source = "hashicorp/local", version = "~> 2.0" }
}
}
resource "local_file" "hello" {
content = "Hello, Terraform!"
filename = "${path.module}/hello.txt"
}
terraform init
terraform plan
terraform apply -auto-approve
Key concepts
- Provider: Plugin for a cloud or service (e.g.
aws,google). - Resource: A piece of infrastructure (e.g.
aws_instance,local_file). - State:
terraform.tfstatestores current state; keep it safe (e.g. remote backend).
Start with the Terraform tutorials.