Infrastructure-as-code with Terraform/OpenTofu — resources, state, modules, plan/apply. Use when writing `.tf` files, managing cloud infrastructure with Terraform or OpenTofu, handling state and backends, or reviewing IaC code.
Terraform (and OpenTofu) describes cloud infrastructure declaratively
and reconciles reality with plan and apply. Pin provider versions,
use a remote state backend, and never edit state by hand — get those
three right and the rest is just resource documentation.
Every project starts with a provider configuration. Pin provider
versions in a required_providers block:
terraform {
required_version = ">= 1.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "eu-central-1"
}
Resources are the core building blocks. Use descriptive names and set critical arguments explicitly rather than relying on defaults.
Use typed variables with descriptions and validation where