Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 16, 2026·3 min de lecture

Terramate — IaC Orchestration for Terraform & OpenTofu

An open-source orchestration tool that adds code generation, stack management, change detection, and drift detection to Terraform and OpenTofu projects. Terramate scales IaC from single directories to hundreds of stacks.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Terramate Overview
Commande d'installation directe
npx -y tokrepo@latest install af4fad9b-39d2-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
Terramate orchestrates Terraform stacks with code generation, change detection, and drift detection at scale.
§01

What it is

Terramate is an open-source orchestration tool that extends Terraform and OpenTofu with stack management, code generation, change detection, and drift detection. It helps teams scale from a single Terraform directory to hundreds of stacks by managing dependencies, ordering execution, and detecting which stacks actually changed.

Terramate targets platform and infrastructure engineers managing large Terraform codebases. If your Terraform project has grown into many modules and environments with complex interdependencies, Terramate brings structure without replacing your existing HCL.

§02

How it saves time or tokens

This workflow provides installation and initialization commands. Instead of running terraform apply across every directory manually, Terramate detects which stacks changed and runs only those. Code generation eliminates copy-paste between stacks, and drift detection alerts you to manual changes.

§03

How to use

  1. Install Terramate:
brew install terramate
  1. Initialize in an existing Terraform repo:
terramate create --name my-stack
  1. Run Terraform through Terramate:
# Detect changed stacks and run plan only on those
terramate run --changed -- terraform plan

# Apply across all stacks in dependency order
terramate run -- terraform apply -auto-approve

# Check for drift
terramate run -- terraform plan -detailed-exitcode
§04

Example

# terramate.tm.hcl - Stack configuration
stack {
  name        = "production-vpc"
  description = "Production VPC and networking"
  tags        = ["network", "production"]
}

# Generate shared backend config across stacks
generate_hcl "_backend.tf" {
  content {
    terraform {
      backend "s3" {
        bucket = "my-terraform-state"
        key    = "stacks/${terramate.stack.path.relative}/terraform.tfstate"
        region = "us-east-1"
      }
    }
  }
}
# Run only on stacks tagged 'production'
terramate run --tags production -- terraform plan
§05

Related on TokRepo

§06

Common pitfalls

  • Terramate does not replace Terraform. It wraps and orchestrates it. Your existing .tf files remain unchanged; Terramate adds .tm.hcl files for stack configuration.
  • Change detection works with Git. Uncommitted changes are not detected by default. Commit your changes or use --changed with appropriate flags.
  • Code generation templates use Terramate's own HCL syntax, not standard Terraform. Review the Terramate docs for template variables and functions.

Questions fréquentes

Does Terramate replace Terraform?+

No. Terramate wraps Terraform and OpenTofu. Your existing HCL files remain untouched. Terramate adds orchestration, code generation, and change detection on top of your existing Terraform workflow.

How does change detection work?+

Terramate uses Git to detect which files changed since the last commit or merge. It maps changed files to stacks and only runs Terraform on affected stacks. This dramatically reduces plan and apply times in large repos.

What is code generation in Terramate?+

Code generation lets you define HCL templates that produce Terraform files. Instead of copy-pasting backend configs or provider blocks across stacks, you write one template and Terramate generates the files in each stack.

Does Terramate support OpenTofu?+

Yes. Terramate works with both Terraform and OpenTofu. Replace terraform with tofu in your terramate run commands. Stack management, change detection, and code generation work identically.

How does drift detection work?+

Run terramate run -- terraform plan -detailed-exitcode across all stacks. Terramate collects the exit codes and reports which stacks have drifted from their desired state. This catches manual changes made outside Terraform.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires