Modules Repo

Connect a git repository as the source of truth for your custom modules, migrate published modules into it, and provenance-check every publish.

A modules repo is the single git repository your control plane treats as the source of truth for custom IaC modules. Modules reach the registry through reviewed git history instead of ad-hoc uploads, and Facets can check every publish against it. Each control plane holds exactly one, and Facets rejects a second registration.

Prerequisite: a linked version-control account, see Integrating Git Accounts. GitHub App accounts need extra permission approval first; see Troubleshooting. GitLab and Bitbucket accounts need no approval. A missing token scope fails at the step that needs it.


Connecting a repo: choosing a route

Using prompt

Set up a modules repo for this control plane.

or

Using command

# Provision one end to end
raptor module bootstrap-repo

# Reconcile an attached repo with the registry
raptor module sync-repo

bootstrap-repo runs the whole first-time setup, the eight steps in What migration does, including the facets-modules-ci service account.

sync-repo is the ongoing one. The control plane clones the repo's default branch and writes every published custom module over it. If the repo already matches the registry it says so and closes any stale sync pull request; if it differs it opens one.

New to the CLI? Install it first.

The two routes below, migrating modules into a new repo or attaching an existing one, are both driven from the Control Plane.

On the Module Registry page, above the module tables, select Connect repo, or Manage if a repo is attached. Two mutually exclusive routes follow: migrate when the target repo is new or empty, or attach when it already holds your modules. Both routes work on GitHub, GitLab and Bitbucket.


Route 1: migrate modules to a new repo

  1. Select Connect repo, then Migrate modules to a new repo.
  2. Choose a new repository or an existing empty one. A new one takes a repository name, a VCS account, and an owner: Organization on GitHub, Group on GitLab, or Workspace on Bitbucket, where it is required. An existing one takes its URL and account.
  3. Under Advanced Options, set a path prefix to place the modules tree under a subdirectory such as infra/modules/…. Facets rejects absolute paths and traversal.
  4. Start the migration and watch progress until it reports success.

A default branch applies only to the existing-repository option; a new repository keeps the provider's own, so Facets rejects a branch name supplied with a repository name.


What migration does

Migration runs as an async job with per-step progress. A failure names the step that stopped, and the job is re-runnable:

  1. Resolve repository
  2. Check repository is empty
  3. Create CI service account
  4. Export modules and output types
  5. Enable CI
  6. Push to repository
  7. Provision CI secrets
  8. Register modules repo

Export unzips every module at the Published stage into the tree below, beneath any path prefix, along with custom output types. Each module leaf holds facets.yaml and the module's Terraform files. Preview-stage modules are skipped.

modules/
  <intent>/
    <flavor>/
      <version>/
        facets.yaml
        *.tf
outputs/
  <namespace>/
    <name>.yaml

Legacy modules registered by git URL before the zip upload flow have no stored file. Facets skips them and lists them on the step detail, re-upload as needed.

Migration also commits the CI pipeline file for your provider, see Continuous Integration, plus a README naming the secrets it needs. The bootstrap commit carries [skip ci], so CI starts on your first change.

The CI secrets are CONTROL_PLANE_URL, FACETS_USERNAME and FACETS_TOKEN, described in Required secrets.


What differs by provider

AreaGitHubGitLabBitbucket
AccountGitHub App or personal access tokenToken or GitLab appToken or Bitbucket app
ReviewPull requestMerge requestPull request
CI file.github/workflows/facets-module-ci.yml.gitlab-ci.ymlbitbucket-pipelines.yml. Pipelines is off on new repositories, so Facets turns it on during Enable CI.
Where the three secrets goActions repository secretsCI/CD variablesSecured repository variables
Set by handSettings → Secrets and variables → ActionsSettings → CI/CD → VariablesRepository settings → Pipelines → Repository variables. Mark FACETS_TOKEN as secured.

CI behaves the same on all three, with no webhooks. Output types go first: a pull or merge request creates only missing ones, and a merge applies changed ones before publishing changed modules.


Route 2: attach an existing repo

Use this route for a repository that already holds your modules. It registers the repository and nothing else, no export, push, workflow, or secrets.

  1. Select Connect repo, then Attach an existing repo.
  2. Enter the repository URL, it must start with http://, https://, or git@, and select a VCS account.
  3. Set the default branch, a path prefix, and an enforcement mode, then save. See Provenance Enforcement.

Your repository must already follow modules/<intent>/<flavor>/<version>/ beneath the path prefix. You wire up CI yourself, see Continuous Integration.


Managing an attached repo

Select Manage to review the repository URL, CI user, default branch, path prefix, and enforcement mode; you can edit the last three. The last bootstrap job replays the eight-step view, showing which modules the export skipped.


Provenance enforcement

Provenance ties a published module to the registered repository. At publish time, Facets checks that the module carries a git ref, a commit SHA, and a git URL matching the registered repo. Both are captured at upload from a git work tree, not at publish. URL matching is normalized, so SSH versus HTTPS or a trailing .git still matches. Upload from a git work tree and publish from a clone of the registered repo, and both checks pass.

ModeWhat happens on a violationWhen to use it
OffFacets does not check provenanceBefore your team publishes from clones
Warn (default, recommended)The publish succeeds. Facets logs the violation, returns it to the caller, and stores it on the module as a publish warningWhile you roll the practice out and watch what trips
EnforceFacets rejects the publishOnce every publish comes from a clone of the registered repo

Rotating the CI token

Select Rotate CI token to regenerate the CI service account's token. Facets updates the CI secret or variable in place where reachable and shows the raw token once, copy it before closing. During migration it appears only when automatic provisioning failed.


Detaching the repo

Select Detach repo and confirm.

Detaching is non-destructive. The git repository, the CI service account, and every published module stay intact. Detaching removes only the registration, so publishes stop being provenance-checked.


Permissions

PermissionGrants
MODULE_READView the module registry, fetch the modules repo, and read bootstrap job status
MODULE_REPO_MANAGEEvery mutating modules repo action: register, update, unregister, rotate the CI token, and bootstrap. Labelled Manage Repository; only Admin has it by default.
MODULE_WRITEPublish and build modules
MODULE_DELETEDelete modules

Without MODULE_READ the page tells you to contact your admin; without MODULE_REPO_MANAGE controls are disabled. Facets audit-logs every mutating action.


Troubleshooting

ProblemCause and fix
GitHub App permissions pendingThe installation lacks the workflow-push or Actions-secrets permission; a pre-flight catches this before any step runs. Approve them, then re-check, the job continues.
Repository-is-empty check failedFacets tolerates only README.md, LICENSE, and .gitignore; the step detail lists what else it found. Empty the repository, or use the attach route.
Some repo secrets not provisionedNon-fatal; the job succeeds. Set them by hand at the path in What differs by provider, using the committed README's names. For the token, use Rotate CI token.
Bitbucket pipeline never runsPipelines is off. Turn it on under Repository settings → Pipelines → Settings.
Push failedFacets surfaces the remote's sideband message. Read it, a branch protection rule is the usual cause.

Tip: You can also perform this operation programmatically. See the API Reference for details.