Skip to main content
Version: Next

Connect Insights

Terrabuild Insights is the optional hosted delivery record for Terrabuild.

What Insights adds​

A connected workspace gains:

  • execution and delivery-group history across developer machines and CI;
  • interactive task graphs and execution context;
  • environment timelines and release notes;
  • GitHub-enriched delivery and engineering signals through Pulse;
  • encrypted managed artifacts shared between authorized machines.

Terrabuild continues to provide its graph, runner, and local cache without an Insights account.

Connection policy​

The workspace either runs locally or participates in the full Insights reporting lifecycle:

  • Without matching workspace credentials, Terrabuild does not create an Insights client. The run and cache remain local.
  • Once Terrabuild connects, opening the run, publishing its graph and artifact metadata, and completing its record are part of the command. A reporting failure fails the command instead of silently leaving an incomplete record.

Remote artifact contents have a narrower failure policy. A missing, corrupt, or unreadable blob is a cache miss. A failed transfer does not discard a completed local cache entry.

1. Create an Insights workspace​

Sign in to Insights, create a workspace, and open Integrations → Terrabuild. Insights provides the workspace block to add to the repository.

WORKSPACE
workspace {
id = "<workspace-id>"
}

The workspace ID is not a secret. It identifies the Insights workspace that receives Terrabuild data.

2. Initialize the workspace and approve users​

Link the repository in Insights. Complete your account identity setup and save the Recovery Kit when prompted. Your identity unlocks automatically while signed in on a remembered browser. On a new browser, enter the recovery key once to connect it. The workspace Owner can then open Security and choose Initialize sharing.

Other users complete their own account setup. A decrypting Owner or Admin opens Security and selects Grant access beside the user's account. The grant applies on every machine using that account identity. Replacement identities can receive existing workspace roots through the same page.

On your computer, run:

terrabuild insights login

Approve the displayed code in Insights. Unlock with your Recovery Kit if needed. The CLI receives the identity through an encrypted handoff and saves it in the OS credential store. No device enrollment or per-device key management is needed.

3. Provision CI​

A workspace Owner or Admin signs in on a connected browser, opens Security, and selects Create CI token. Choose a name and whether the job may publish. The browser generates the token locally, proves possession of its derived wrapping and signing keys, registers it, and grants workspace access.

Use Terrabuild 0.209.1 or later. Copy the token directly into the CI provider's secret store as TERRABUILD_TOKEN. Wait for Workspace access granted, confirm I saved this token in my CI secret store, and finish setup. The secret cannot be retrieved later. If the page says a token is waiting to be saved, use Resume setup to finish. Jobs that only restore artifacts should leave publishing permission disabled.

TERRABUILD_TOKEN is the only Insights secret required by CI. Remove legacy TERRABUILD_MASTER_KEY configuration and replace old server-issued tokens with new tokens created in Insights. A personal Recovery Kit is for human identities and is not a CI secret. The new protocol repopulates the remote cache.

Issue a different token for each Insights origin and workspace. Insights receives a derived authentication credential and public keys. The raw token can derive the private keys, so anyone who obtains it can use that CI identity.

Owners and Admins can list and revoke workspace tokens, but cannot retrieve their secrets. A token also depends on its creator retaining active workspace membership as an Owner, Admin, or Contributor. Removing or suspending the creator, or changing their role to Viewer, stops the token from working.

A revoked token is denied on its next API request. Artifacts accepted before revocation remain eligible for restore by currently authorized readers. Previously signed artifact URLs can work until they expire, and revocation cannot remove keys or files already copied. A decrypting administrator can rotate the workspace key from Security. If every holder loses the root, the Owner can reset it there and rebuild the remote cache. Anyone holding a workspace root can decrypt every artifact encrypted under it across that workspace's repositories.

4. Publish managed artifacts​

A workspace contributor or administrator can publish using an approved account key or contributor CI token. To share a target's declared files, set its artifact policy to ~managed:

WORKSPACE
target build {
artifacts = ~managed
depends_on = [ target.^build ]
}

Terrabuild compresses and encrypts the selected files before upload. Another connected machine with a workspace grant can restore them when it computes the same target identity in the same repository.

Use ~external for artifacts owned by a registry and ~none for side effects. See Caching for the complete ownership model.

A CI workflow may build and plan before an approval, then apply in a separate job. Give both commands the same group identifier:

terrabuild run build test dist plan \
--environment production \
--group "${GITHUB_REPOSITORY}:${GITHUB_RUN_ID}"

terrabuild run deploy \
--environment production \
--group "${GITHUB_REPOSITORY}:${GITHUB_RUN_ID}"

Insights presents them as one delivery group while preserving the two execution records.

CI example​

Install Terrabuild 0.209.1 or later before these GitHub Actions steps. Only the login step needs the CI secret; repeat login in each job that uses Insights. The workspace ID must match both WORKSPACE and the token's workspace.

- name: Connect Terrabuild to Insights
env:
TERRABUILD_TOKEN: ${{ secrets.TERRABUILD_TOKEN }}
run: |
printf '%s\n' "$TERRABUILD_TOKEN" | terrabuild login --workspace "<workspace-id>"

- name: Build and test
run: terrabuild run build test --group "${{ github.repository }}:${{ github.run_id }}"

- name: Remove Terrabuild credentials
if: always()
run: terrabuild logout --space "<workspace-id>"

On GitHub Actions, an environment secret overrides a repository or organization secret with the same name. When replacing an organization token, update or remove any older TERRABUILD_TOKEN at those narrower scopes. See GitHub's secret precedence rules.

Production Insights uses https://api.magnusopera.io/terrabuild by default. For a token issued by staging Insights, set TERRABUILD_API_URL=https://api-staging.magnusopera.io/terrabuild at job scope so login and every subsequent command use the same origin. Production and staging tokens are not interchangeable.

On GitHub Actions, Terrabuild uses a private credential directory under RUNNER_TEMP. Other CI providers must set TERRABUILD_CI_CREDENTIAL_DIR to an absolute, private directory unique to the job, shared across its steps. Log out and remove that directory during teardown, including after failures.

Use --local-only for a run that must neither report to Insights nor read or write the managed cache. Local caching remains enabled.

Next steps​