Skip to main content

Overview

Infrastructure changes flow through Terramate and GitHub. Whether you’re modifying an existing stack, adding a new resource, or creating entirely new infrastructure, the workflow is the same: make changes locally, open a PR, review the plan, and merge to apply.

Workflow

1

Make your changes

Edit the relevant files in terraform/. This might be:
  • Stack configuration (config.tm.hcl, inputs.tm.hcl)
  • Module code in terraform/modules/
  • New stack definitions (stack.tm.hcl)
2

Generate files (if needed)

If you changed any Terramate configuration (.tm.hcl files), regenerate the Terraform files:
This updates generated files like _backend.tf, _provider.tf, and _main.tf.
3

Validate locally (optional)

Test your changes before pushing:
4

Open a pull request

Push your branch and open a PR. The CI workflow will:
  1. Check Terramate formatting
  2. Detect changed stacks
  3. Run terraform plan for each affected stack
  4. Sync preview results to Terramate Cloud
5

Review the plan

Check the plan output in:
  • GitHub Actions logs
  • PR comment with plan summary (if using Terramate Cloud)
  • Terramate Cloud dashboard (for a unified view across stacks)
Look for:
  • Expected resource changes (create, update, destroy)
  • No unintended side effects
  • Correct dependency ordering
6

Merge to apply

Once approved, merge the PR. The deploy workflow will:
  1. Detect changed stacks
  2. Apply changes in dependency order
  3. Sync deployment results to Terramate Cloud
Use GitHub branch protection rules to control who can deploy infrastructure changes. Consider requiring PR approvals, setting up CODEOWNERS for the terraform/ directory, and requiring status checks to pass before merging.

Common Tasks

Adding a New Stack

  1. Create directory under terraform/live/{stage}/{region}/:
  2. Create stack.tm.hcl:
    Replace <region-abbrev> (e.g., use2) and <REGION> (e.g., us-east-2) with your values.
  3. Create config.tm.hcl with stack-specific globals
  4. Create main.tf or use module mixins
  5. Generate files:
    You may need to run terramate generate twice. The first pass generates _outputs.tm.hcl for some stacks (e.g., EKS), which is then used by dependent stacks in the second pass.

Modifying a Module

  1. Edit the module in terraform/modules/{module-name}/
  2. Open a PR - Terramate will plan all stacks that use the module
  3. Review plans across all affected environments
  4. Merge to apply changes everywhere

Targeting Specific Stacks

Use tags to run commands on specific stacks:

Troubleshooting

”Repository has untracked files”

Terramate requires a clean git state. Either stage your changes or use:

Missing dependency outputs

When a dependency stack hasn’t been applied yet, Terramate uses mock values. This is expected during initial bootstrap. Apply stacks in dependency order:

Regenerate after config changes

If you see drift between generated files and configuration:

Configuration Reference

Root Configuration

The terraform/config.tm.hcl defines globals inherited by all stacks:

Terramate Project Configuration

The terramate.tm.hcl at the repository root configures Terramate features:

Stack Definition

Each stack requires a stack.tm.hcl:

Stack-Specific Configuration

Override globals in config.tm.hcl within each stack:

Outputs Sharing

Cross-stack dependencies without terraform_remote_state:
The input becomes a regular Terraform variable, usable in your module:

Terramate Scripts

The terraform/scripts.tm.hcl file defines reusable commands used by CI:

Mixins

Code generation templates live in terraform/imports/mixins/. These generate common files (_backend.tf, _provider.tf, _main.tf) from templates, eliminating copy-paste between stacks.