Handle secrets
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
Read https://intentius.io/terragucci/guides/keep-secrets-out-of-notes/.
Find every secret this repo's roots read and say how each one reaches the job: `pass.secrets`, `secrets` from a cloud's store, a CI/CD variable on GitLab, or nothing.
List each variable in this repo's roots that holds a secret and is not marked `sensitive = true`, and each secret a root reads that terragucci.yml does not name under `pass.secrets`.
Add the missing names and `sensitive = true`, run `npx terragucci config check --json` and `npx terragucci init`, and open a pull request. Print names only; never write a secret's value anywhere.
Never apply, approve (a pull request review or `terragucci approve`), override a policy denial (`terragucci override`), use `--mode apply`, or merge; never touch `.chant/allowed_signers` or `chant/lifecycle`.Result
Section titled “Result”A value reaches a root by name, and nothing terragucci writes holds it:
| Piece | How | Section |
|---|---|---|
| Inputs | a root reads a secret by name from the forge’s store (pass.secrets) or from a cloud’s secret store (secrets); the config holds names and paths, never values |
Inputs, Steps |
| Cloud access | with oidc, each job trades the forge’s OIDC token for a cloud role, so no long-lived cloud key is stored |
Cloud access |
| Outputs | sensitive values are redacted in the plan files, the note, the report and terragucci’s log; messages carry no plan values | Redaction |
| Tokens | forge tokens are removed from the environment the binary, Terragrunt and the policy engine start with | Tokens |
| State | the backend’s encryption and each environment’s state roles; an export needs a second person | State |
Inputs
Section titled “Inputs”pass.secrets maps repository secrets by name into the jobs that plan and apply. A workflow on any branch a writer pushes can read a repository secret. An environment secret reaches only the jobs of that environment, past its deployment branch rule: name an environment’s roots in environments and its apply jobs run in it (Separate environments).
pass.secrets is not needed here. An unprotected variable reaches every branch’s pipelines. A protected variable reaches only protected refs, and one with an environment scope only that environment’s jobs.
pass.secrets maps repository secrets by name, as on GitHub. A workflow on any branch a writer pushes can read them, and Forgejo has no environment secrets: keep an environment’s secrets apart with a repository of its own.
-
Put the value in your forge’s secret store, named as the root reads it, such as
TF_VAR_db_password(on GitLab, a masked CI/CD variable). To keep it in AWS Secrets Manager, GCP Secret Manager or Azure Key Vault instead, read it there with the root’s own identity throughsecrets, and skip step 3. -
Mark the variable sensitive in the root:
variable "db_password" {type = stringsensitive = true} -
Name the secret in
terragucci.yml. The pipeline holds the name, never the value:pass:secrets: [TF_VAR_db_password]config checkrefuses a value written in place of a name. On GitLab every job reads the CI/CD variables already, so the key changes nothing there. -
Check the file and write the pipeline again:
Terminal window npx terragucci config checknpx terragucci initEach job that plans or applies gets the secret as an environment variable of that name; Secrets and variables you pass lists the jobs that get none.
-
Open a pull request. When the plan held a sensitive value, the note says so:
Sensitive values are redacted in the stored plans (2).
Redaction
Section titled “Redaction”The binary’s show -json prints sensitive values in plain text. Each one is redacted before a plan is kept anywhere.
| Where | The value becomes |
|---|---|
plan.json and the report |
(sensitive, redacted by terragucci), wherever the value appears, also in an attribute the plan does not mark |
plan.txt and the plan note |
(sensitive value), as the binary prints it, wherever the value appears |
| a policy denial or warning | redacted before it reaches the report, the note or the log |
| a write-only attribute | its version (*_wo_version); the value is never in the plan |
| an ephemeral value | not reported |
a value secrets read from a cloud’s store |
redacted as a sensitive value, whether or not its variable is marked: wherever it is a whole value of the plan, and wherever a value of eight characters or more appears in the note, the report and terragucci’s log lines |
Plan digests are taken before redaction, so an approval binds the plan as planned. The policy engine reads the unredacted plan.
A chat or webhook message names the wave and links the run; it carries no value from a plan. A webhook’s address is a secret and is never printed.
Cloud access
Section titled “Cloud access”With oidc, every job that reaches the cloud trades the forge’s token for a role, a service account or a client, so no cloud key is stored in the forge. The reports bucket takes the same identity through reports.role, or the job’s own role. Keys are the fallback only: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, or AZURE_STORAGE_KEY, as secrets the jobs that plan get (Reports). Leave them unset and set reports.role, or give the job’s role write access to the reports, to store none.
Tokens
Section titled “Tokens”| Token | Held by | Kept from |
|---|---|---|
the run’s own token, or GITLAB_TOKEN |
the generated jobs that post or push | the binary, Terragrunt and the policy engine, in every stage that runs them (Forge tokens) |
| any forge token, on GitHub and Forgejo | the steps of the check, plan and replan jobs before the step that runs the pull request’s code; on GitHub, the later steps hold only the artifact upload’s runtime token, and on Forgejo the step that runs the code is the job’s last, its report going on to a job in a fresh container |
the steps that run that code, and on Forgejo with oidc the token-request variables, which carry the run’s token; Token scrub limits has each row |
| the merge token, the agent’s token, the relay’s token and the signing keys | the jobs, relay and people Access and identity lists | every other job |
Limits
Section titled “Limits”| Case | What happens |
|---|---|
| a value not marked sensitive | it is in the plan, the note and the bucket like any other attribute; mark it, or keep the bucket private |
| a provider or a step that prints a value | it reaches the job log as printed; a value from secrets is masked there on GitHub and Forgejo, and on GitLab replaced only in what terragucci prints |
| a passed secret in the plan job | the pull request’s code runs there with it, as with the providers’ credentials; a fork’s pull request gets no plan job |
| the state | holds every secret its resources hold; reports and the bucket keep version ids only, and terragucci state export writes a version only to the machine of the person who runs it |
A state holds every secret its resources hold. It stays in your backend, under the backend’s encryption. Each plan report counts the sensitive values a root’s state holds. When a write-only argument or an ephemeral resource could keep one out of state on the root’s binary and provider versions, the tip terragucci-secret-in-state names it, and the estate page lists the counts per root. Under choudoufu, an estate keeps its records in a record store, and the tip terragucci-choudoufu-secrets names each root whose live block lets secret values reach it. Jobs reach it with each environment’s state roles (Keep each environment’s roles to its own state). Reports and the bucket keep version ids only. terragucci state export writes a version to the machine of the person who asked, once someone else approved the request.
- Sensitive values in the plan report.
- Threat model for what each job can reach.
terragucciHelp setting it up: Intentius
These docs count page views and clicks with PostHog. They set no cookies, store nothing in your browser, and send nothing when your browser asks not to be tracked.