Getting Started with Terraform
Ben Bolton
- One minute read - 142 wordsGetting Started with Terraform
Terraform is an Infrastructure as Code (IaC) tool by HashiCorp that lets you define and provision infrastructure using a declarative configuration language (HCL).
Why Terraform?
- Cloud-agnostic - Works with AWS, GCP, Azure, and hundreds of providers
- State management - Tracks what’s deployed via a state file
- Plan before apply - See what will change before it happens
Basic Concepts
Providers
Providers are plugins that let Terraform talk to APIs:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "eu-west-1"
}
Resources
Resources are the things you want to create:
resource "aws_s3_bucket" "my_bucket" {
bucket = "my-unique-bucket-name"
}
The Workflow
terraform init # Download providers
terraform plan # Preview changes
terraform apply # Apply changes
terraform destroy # Tear it all down
More Terraform posts coming.