advanced

Terraform

Declare provider-managed infrastructure with plans, modules, variables, state backends, and lifecycle controls.

Terraform declares desired infrastructure through providers, resources, modules, variables, plans, and state. The plan/apply workflow makes changes reviewable before they touch real cloud resources.

					resource "aws_s3_bucket" "assets" {
  bucket = var.bucket_name
}

output "bucket_name" {
  value = aws_s3_bucket.assets.id
}
				

Run `terraform plan` in CI on pull requests. Apply production only through gated pipelines with remote state locking.

On interviews: remote state, locking, modules, provider version pins, drift, workspaces versus separate state files, and import workflows.

Common pitfalls: console changes create drift; weak module boundaries make every change risky; local state in Git.

The trade-off is declarative simplicity versus state management discipline and module design overhead.

Checklist:

  • Use remote locked state.
  • Review plans in CI.
  • Pin provider and module versions.
  • Detect and remediate drift regularly.