Workflows and discovery config¶
The repository holds no engine code. Five caller workflows in .github/workflows/
hand everything to the nrit-tfpr engine, and projects.yml at the root
tells the engine what to discover, what to leave alone, and which gates to run.
This page covers all of them, the two runner checks, the CODEOWNERS file the
bootstrap writes, and the pull request template that ships alongside.
The five callers, and which half of the engine each one uses:
| File | Trigger | Calls |
|---|---|---|
tfpr-pr.yml |
pull_request: opened, synchronize, reopened |
The dispatch composite action |
tfpr-unlock.yml |
pull_request: closed |
The dispatch composite action |
tfpr-review.yml |
pull_request_review: submitted, dismissed |
The dispatch composite action |
tfpr.yml |
issue_comment: created, and workflow_dispatch |
The terraform-pr-ops.yml reusable workflow |
drift.yml |
cron: "17 6 * * *", and workflow_dispatch |
The drift.yml reusable workflow |
Three callers pin a composite action, two pin a reusable workflow. Each carries one version pin; see the pins below.
.github/workflows/tfpr-pr.yml¶
The pull request path. Two jobs, in order:
pre-commit runs first and gates everything. It installs the toolchain from
mise.toml (so it runs the same formatter, tflint, checkov, and invariants
versions as a local pre-commit install does) and runs the hooks on the files
the pull request changed, from the base commit to the head. That symmetry is
the point: the hooks catch problems at commit time, and this job catches a
commit made without them (or with --no-verify) before it reaches main. Main
is already clean because every merge passed this same gate, so the diff is
enough; hooks that do not take filenames, such as the repository invariants,
still scan the whole tree. The changelog reminder rides along
as a step in the same job: when a pull request changes code but not
CHANGELOG.md, it emits a warning annotation without failing.
The repository invariants live in .github/scripts/check-repo-invariants.sh.
What they guard and why is on
Policy, security, and cost gates.
dispatch needs pre-commit, so a failed lint stops the dispatch entirely:
no plan runs, no report lands, and merge stays blocked because the required
merge gate is never created. When the hooks pass, the
tfpr/.github/actions/dispatch composite action dispatches the ops
workflow on the default branch with the PR number, and nothing else. This
job runs the PR branch's own copy of the caller, which any writer can edit,
so it takes no inputs, holds no secret and writes no check: the ops run
resolves the PR from the API, opens the merge gate and the per-unit rows, and
completes them.
Its permissions:
No id-token here: this caller never touches Azure.
.github/workflows/tfpr-unlock.yml¶
Releases the PR's cross-PR unit locks when it closes, merged or not. It is its
own workflow so a merged PR's checks list shows one row that reads as lock
release, instead of a skipped pre-commit row and a duplicate dispatch row
stacked on the last real run. It runs the same dispatch action, so it also
needs only contents: read plus actions: write.
.github/workflows/tfpr-review.yml¶
Refreshes the tfpr / approval row when a review is submitted or
dismissed. A review starts no plan, so without this caller the row keeps the
last run's verdict. Its refresh job runs the same dispatch action, with the
same contents: read plus actions: write, and the ops run it starts only
rewrites the approval row; it plans nothing and leaves the merge gate alone.
Its own workflow, like the unlock caller, so a review adds no skipped rows.
.github/workflows/tfpr.yml¶
The ops caller: comment commands and dispatched work. Most engine releases
need only the pin bump here. A release that changes the workflow_dispatch
inputs needs an edit and a two-PR bump; see
How to upgrade the engine.
The same file tracks the Terraform side, under live/ only (includePaths):
- Registry modules. Renovate's
terraformmanager reads everysourceandversionpair in the units. All module bumps arrive in one pull request. AVM modules can break on a 0.x minor, so read the release notes and every unit's plan. If a module needs a newer provider than a unit's lock file allows, init fails: refresh that lock file withterragrunt run -- providers lock -platform=linux_amd64in the same pull request. - Provider constraints. A second regex manager reads the
required_providersconstraints inside the Terragruntgenerateblocks inroot.hcland any unit override. Only a version outside the range counts, for example a new azurerm major against~> 4.0. It is listed on the dependency dashboard issue and opens no pull request until you tick it there, because a provider major only works once the AVM modules support it.
Renovate does not update lock files. Versions inside a constraint arrive when you refresh a lock file.
It triggers on two things:
issue_commentwith typecreated, which is howtfpr plan,tfpr apply, andtfpr unlockcomments reach the engine.workflow_dispatch, with acommandchoice input (plan,apply, orunlock, defaultplan) and an optionalprojectinput to target a single unit, pluspr_number, which every dispatch needs. The PR caller's dispatch action also setsbefore_shaandtrigger_actor, hints for the report wording. The engine trusts none of the inputs for a decision: it resolves the PR, its head and its units from the API, so a dispatch by hand runs exactly like atfpr plancomment.
The permissions block is a ceiling, not a grant to this file. A reusable
workflow cannot ask for more than the caller holds, so the caller has to declare
everything the engine's jobs use:
pull-requests: write posts and edits the run comment and its reactions,
checks: write writes the engine-authored check runs (merge gate included),
and id-token: write mints the OIDC token for Azure. Cut any of them and the
engine fails inside the reusable workflow, not here.
The single job calls the reusable workflow:
jobs:
engine:
uses: nrit-solutions/tfpr/.github/workflows/terraform-pr-ops.yml@vX.Y.Z
with:
command: ${{ inputs.command || 'plan' }}
project: ${{ inputs.project || '' }}
pr_number: ${{ inputs.pr_number || '' }}
before_sha: ${{ inputs.before_sha || '' }}
trigger_actor: ${{ inputs.trigger_actor || '' }}
# Pass the secrets by name. GitHub drops secrets: inherit when the caller
# is in another organization than the reusable workflow.
secrets:
TFPR_CHECKS_APP_PRIVATE_KEY: ${{ secrets.TFPR_CHECKS_APP_PRIVATE_KEY }}
INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
The current pin is on Versions and upgrades.
.github/workflows/drift.yml¶
The daily drift sweep. It runs on cron: "17 6 * * *", so 06:17 UTC every day,
and also on workflow_dispatch with no inputs.
Its permissions are deliberately different:
permissions:
contents: read
issues: write
id-token: write
pull-requests: read # the lock sweep reads holder PR state
Drift reports as GitHub issues, not as a pull request comment, so it needs
issues: write and no write access to pull requests or checks.
pull-requests: read is for the lock sweep: the drift run releases every unit
lock whose holder PR has closed, and it reads the holder's state to decide.
The job takes no inputs, and it passes the same two secrets by name.
The pins¶
Each of the five callers carries one pin, its uses: ref. In the two
reusable-workflow callers (tfpr.yml, drift.yml) it selects the
workflow body, and each job installs the engine runtime (the tfpr binary and
the gate scripts) from that same release. The three action callers
(tfpr-pr.yml, tfpr-unlock.yml, tfpr-review.yml) pin the
dispatch action. Five pins across five files, all at the same exact version, so a run only changes when
someone commits a new one.
Bump all five pins together
If the pins skew, the pull request path and the comment path run different
engines. Change every @vX in the same commit, in all five caller files.
The repository invariants fail a commit whose callers pin different
releases, except the first half of a two-PR bump (the ops and drift
callers ahead of the PR, unlock, and review callers). The current pins are on
Versions and upgrades.
The runner checks¶
Two more workflows ship with the template. Neither calls the engine.
runner-canary.ymlruns on a schedule on a GitHub-hosted runner. It opens an issue when a workflow run waits in the queue longer than 30 minutes, which means the self-hosted runners are not scaling up, and closes it on the next healthy pass.runner-egress-check.ymlruns on dispatch only, on the self-hosted runner. It reports which endpoints the plan path depends on the runner can reach, and whether checkov findings carry guideline links. It reports and never fails.
The shipped-text check¶
shipped-text.yml runs only in the template repository, on pull requests and
pushes to main. Every file in the template ships into each generated
repository, so it fails when a shipped file matches a denylist pattern held in
a repository variable. In a generated repository the job skips: the
repository is not a template and the variable is unset. It does not call the
engine.
.github/renovate.json¶
Renovate keeps the engine pins current once the
Renovate GitHub App is installed on the
repository; without the App the file does nothing. Installing the App sends
you to developer.mend.io to onboard the organization: choose interactive mode,
because silent mode opens no pull requests. A regex manager reads the
five tfpr uses: refs and looks up the public release tags. A minor or
patch release opens one pull request for all five callers. A major release opens
two: step 1 moves the ops and drift callers, step 2 the PR, unlock and review callers,
and Renovate rebases step 2 once step 1 is on main. Until then step 2 fails the
pin check on purpose. See
How to upgrade the engine.
See The PR-ops engine for how the pin is verified at run time and what branch protection to set.
Secrets passed by name¶
The two reusable-workflow callers pass two secrets by name:
TFPR_CHECKS_APP_PRIVATE_KEY and INFRACOST_API_KEY. The two action callers
pass nothing. Do not switch to secrets: inherit: GitHub honours it only
when the caller and the reusable workflow share an organization, and the
reusable workflows live in nrit-solutions, so a repository in any other
organization would run every plan, apply and drift job with the keys empty.
Inside nrit-solutions both forms work; the named form is the one that works
everywhere, and it keeps unrelated secrets away from the engine. The
Security model page covers the blast radius.
.github/CODEOWNERS¶
The template ships none. The bootstrap writes it once, when it creates the
repository, and the repository owns it from then on. It gives .github/ and
projects.yml to the apply approvers team the bootstrap creates
(@<organization>/<customer_name>-alz-apply-approvers): the engine callers, the
gate hooks, and the invariants script that guards them. With the bootstrap's
require_code_owner_review on (the default), a pull request touching those paths
needs that team's approval. A repository created before the bootstrap wrote the
file sets write_codeowners = false.
GitHub skips a line whose owner it cannot resolve, and the path then needs no owner review. The file view on GitHub flags such a line.
.github/pull_request_template.md¶
Three sections. What and why is free text. Scope asks for the units
impacted, the subscription or landing zone, and any version pins moved, which the
template spells out as the AVM version in main.tf, the policy library ref,
and the engine pins.
Then a seven-item checklist:
- Plan comment reviewed for every impacted unit, including deletes and replaces
- Policy, security, and cost gate output reviewed
- If an engine pin moved, every pin in the five caller workflows matches
- Affected
customer.hcl/subscription.hcl/env.hcl/region.hclvalues confirmed - Reviewer from the required approver group requested (and the code owner, if
.github/orprojects.ymlchanged) tfpr applyrun after approval and the apply succeededtfpr / merge-gateis green
The last two matter for the merge gate. It stays red until the change is applied, so applying is part of the pull request, not something that happens after merge.
projects.yml¶
This is the repository's actual discovery config, not the schema. For every field and all three discovery modes, see projects.yml schema.
terragrunt:
root: live
include_dependents: true
gate_ignore:
- ".tflint.hcl"
- ".claude/**"
extra_env:
- INFRACOST_API_KEY
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"
root: live points discovery at the directory holding root.hcl.
include_dependents: true means an impacted unit pulls its downstream dependents
into the same run, so a plan shows the full effect of the change and an apply runs
in dependency order.
A unit is impacted when its own directory changed, when a file it reads changed, or
when it is downstream of a unit that is. The read-files part matters here: every
unit reads root.hcl, customer.hcl, tenant.hcl, and the subscription.hcl, env.hcl
and region.hcl above it, so a one-line change to live/root.hcl impacts the whole tree. See
Plan and apply.
gate_ignore: names the Terraform-pattern paths that belong to no unit on
purpose. The merge gate fails a pull request whose changed
Terraform paths no planned unit accounts for; these globs are the deliberate
exceptions (linter configuration, bundled tooling). Keep the list short: every
entry is a place where Terraform can change without the gate noticing. See
the merge gate.
extra_env: names environment variables the engine forwards to terraform and
the hooks on top of its allow-list. The cost gate needs INFRACOST_API_KEY.
The engine reads this list from the default branch, never from the pull
request. Review an addition like code: PR code in the plan job can read every
name listed here.
There is no exclude. The foundation is governed like any other unit: plan review,
required approvals, and the merge gate. Excluding it would hide the highest-impact
units from the same scrutiny, so it stays in.
The three post_plan hooks are the policy, security, and cost gates, and they run
on every plan and every drift plan, not on apply. What they do and how to
enforce them is on
Policy, security, and cost gates.
$TFPR_ENGINE_DIR is exported into the hook environment by the engine and points at
the engine runtime installed from the pinned release. The gate scripts live in the engine, not
in this repository, so hooks resolve them there rather than in the consumer
workspace. That also means a pull request cannot edit a gate script to weaken its
own gate.