Skip to content

projects.yml schema

projects.yml at the repo root tells the engine what to discover and which hooks to run. There are three discovery modes. Terragrunt mode is exclusive; the two plain-Terraform modes can be combined.

The engine's vocabulary is project; in Terragrunt mode a project is exactly a unit, and this site uses the two words interchangeably.

Terragrunt mode

terragrunt:
  root: live               # directory that holds root.hcl
  include_dependents: true # re-plan a changed unit's downstream dependents
  exclude:                 # optional globs, relative to root
    - "**/scratch/**"
  tool: terragrunt         # optional

The shipped configuration has no excludes, on purpose: the foundation units are the highest-impact part of the tree, and excluding anything from discovery hides it from the plan, the gates, and the merge gate.

Discovery uses native Terragrunt (terragrunt find with dependencies, the DAG and the files each unit reads). A changed unit impacts that unit plus every downstream dependent, in topological order, so apply runs in the right sequence. A changed shared file (tenant.hcl, a region.hcl, anything root.hcl reads) impacts every unit that reads it. Nothing is declared for that: the merge gate checks the selection against the same reading map taken from the default branch, so a pull request cannot shrink its own run by editing HCL (the gate then reads "Discovery disagrees with the changed files"). A changed Terraform-pattern file that no unit on the default branch reads is an unattributed path unless gate_ignore covers it.

The gate_ignore block

gate_ignore:               # optional globs, always repo-relative
  - ".tflint.hcl"
  - ".claude/**"

The merge gate fails a PR whose changed Terraform-pattern paths belong to no selected unit (see the merge gate). gate_ignore: names the paths that belong to no unit on purpose: linter configuration, bundled tooling, a shared module tree. The globs work like exclude (a pattern covers its subtree) but are always repo-relative, in both modes, because the paths they cover live outside the units by definition. Keep the list short: every entry is a place where Terraform can change without the gate noticing. A pull request that only touches paths on the list counts as no Terraform change, so it merges with no unit planned. The engine reads the list from the default branch, so a new entry lands in its own pull request before the files it covers.

The extra_env block

extra_env:                 # optional, read from the default branch only
  - INFRACOST_API_KEY

Terraform, Terragrunt and hooks run with an allow-listed environment, and nothing GitHub-side is in it (see the hook and step model). extra_env names further variables to forward from the job's environment. The cost gate needs INFRACOST_API_KEY here, or it reads "skipped, no INFRACOST_API_KEY". Like the hooks, the list is read from the default branch, never from the pull request. Keep it short and review it like code: every name on it is readable by pull request code in the plan job.

Explicit projects (plain Terraform)

projects:
  - name: prod
    dir: environments/prod
    tool: terraform

The label is <dir>/<name>.

Generated projects (plain Terraform)

generate_projects:
  include:
    - "environments/**"
  exclude:
    - "**/modules/**"
  traverse_to_nested_projects: true   # default true

Every folder with *.tf under an include glob (minus excludes and shared modules) becomes a project, labeled by its path. Globs support **.

By default the walk keeps descending inside a project, so a nested folder with its own *.tf files becomes a second project. Set traverse_to_nested_projects: false to stop at the first project on each branch, so a modules/ folder inside a root never becomes a project of its own without needing an exclude glob.

The drift block

drift:
  enabled: true    # default true
  include:
    - "live/**"
  exclude:
    - "sandbox/**"

Scopes or disables the daily drift sweep. With no drift: block, every discovered unit is swept.

The steps block

steps:
  post_plan:
    - name: Policy check (conftest)
      run: bash "$TFPR_ENGINE_DIR/scripts/conftest-gate.sh"
    - name: Security scan (avmsec)
      run: bash "$TFPR_ENGINE_DIR/scripts/avm-policy-gate.sh" avmsec
      on_failure: warn
    - name: Reliability check (APRL)
      run: bash "$TFPR_ENGINE_DIR/scripts/avm-policy-gate.sh" aprl
      on_failure: warn
    - name: Security scan (checkov)
      run: bash "$TFPR_ENGINE_DIR/scripts/checkov-gate.sh"
      on_failure: warn
    - name: Cost estimate (infracost)
      run: bash "$TFPR_ENGINE_DIR/scripts/infracost-gate.sh"

This flat form is the plan stage only: the hooks run on every plan and every drift plan, and not on apply, which re-takes a plan the guard has already matched to the reviewed one. To run hooks at apply time, nest the stages:

steps:
  plan:
    post_plan:
      - name: Policy check (conftest)
        run: bash "$TFPR_ENGINE_DIR/scripts/conftest-gate.sh"
  apply:
    post_apply:
      - name: Notify
        run: ./scripts/notify.sh

A flat pre_apply or post_apply, or a misspelt slot, fails discovery with the fix named.

Each hook is a mapping: name is its row title in the PR comment, run is the shell command, and on_failure is block (the default) or warn, which reports a failure as an open warning row without blocking merge or apply. A plain command string is refused by discovery with the edit printed. See the hook and step model.

$TFPR_ENGINE_DIR points at the engine runtime the reusable workflow installs. It defaults to the workspace, so the same paths resolve in vendored mode.

Hooks run at fixed seams around init, plan, and apply. A global steps: applies to every unit. In plain-Terraform mode a projects: entry may set its own steps:, which fully replaces the global one (there is no merge). Hooks are always read from projects.yml on the default branch. See the hook and step model.

One parser, loud failures

Discovery is a compiled part of the engine with a single parser for this file. A malformed or contradictory config fails the run with a named error rather than being silently ignored, and a terragrunt: block that supersedes projects: or generate_projects: says so in the run log.