Skip to main content

Terraform

This section documents our opinionated approach to writing, organizing, and operating Terraform code. It covers naming conventions, structural guidelines, state management, and everyday best practices that every engineer working on infrastructure should follow.

Sections

SectionDescription
Naming ConventionsStandardized resource and variable naming patterns
BackendsRemote state configuration and locking strategies
Module StructureHow to structure reusable Terraform modules
Code OrganizationRepository layout and file structure guidelines
Variables & OutputsVariable typing, validation, and output conventions
ProvidersProvider version pinning and configuration
ModulesModule design principles
Secrets ManagementKeeping secrets out of version control
CI/CD PipelineWorkflow rules, validations, drift detection, and GitHub Actions pipeline setup
Lifecycle & Version ManagementDestroy protection and Terraform version pinning

Guiding Principles

  • Consistency over preference: follow the patterns in this playbook even when you disagree; raise a discussion to change the standard instead of diverging silently.
  • Least privilege by default: every IAM permission, policy, and role should grant only what is needed.
  • State is sacred: treat the Terraform state as production data; protect it with encryption, access controls, and locking.
  • Code review everything: no terraform apply runs directly from a developer machine against production; all changes go through CI/CD.