Query the estate
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
Read https://intentius.io/terragucci/guides/query-with-sql/.
Write the terragucci query command that lists the resources of type aws_sqs_queue changed in the last 7 days with their approvers, for this repo's reports bucket, and run it. Do not create or print credentials.
Read only. 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`.Which queues changed this week, and who approved each change? The estate page shows one resource at a time. terragucci query reads one table across every project and keeps the rows that match its filters. The bucket’s tables come from the files your runs already wrote to the reports bucket. The gates and approvals come from the repo’s chant/lifecycle branch. There is no server and no database to run.
Result
Section titled “Result”npx terragucci query history --where type=aws_sqs_queue --since 7d --json \
| jq -r '.results.rows[] | [.address, .actions, .approver, .finished] | @tsv'aws_sqs_queue.jobs create approver-one 2026-10-09T05:15:39.686Z
aws_sqs_queue.jobs update approver-two 2026-10-09T05:15:54.614ZWithout --json, the rows print as an aligned table of every column, with a count of the rows the filters kept out of the table’s rows.
Each approver is the one the audit trail records for the wave that applied the change.
Filters
Section titled “Filters”| Flag | Keeps |
|---|---|
--where <field><op><value> |
the rows where the field compares true. Give it more than once and every clause must hold. |
--since <time> |
the rows from that time on, an ISO date or time or a span back from now such as 7d or 24h. It compares finished in the bucket’s tables (at in audit), and each ledger table’s own time column. |
--at <rev> |
the ledger tables as a commit of chant/lifecycle held them, such as chant/lifecycle~3. |
The operators are =, !=, <, <=, >, >= and ~ (contains, on text). null matches an empty value with = and !=. A field that holds JSON takes a key under it, such as detail.approval=sha256:.... Quote a clause with < or > in your shell: --where 'wave>=2'. A field the table does not have, or a value that does not read as the field’s type, is refused before anything is read.
Tables in the reports bucket
Section titled “Tables in the reports bucket”| Table | One row per | Read from |
|---|---|---|
inventory |
resource a root holds, as its newest applied wave left it | each project’s inventory.json |
versions |
binary, provider or module version a root runs, as its newest applied wave left it: kind is binary, provider or module, name the binary, the provider’s address or the module’s source, and call the module call |
each project’s versions.json |
changes |
resource an applied wave changed | each project’s changes.json |
history |
change, with its wave’s approver and approval entry id |
changes.json joined to audit.jsonl |
audit |
audit trail entry | audit.jsonl |
edges |
root whose state another root reads | each project’s edges.json |
Columns keep the field names of the JSON the bucket holds, with project added.
actionsjoins a change’s actions with+, such ascreateormove+update. Match one with~:--where actions~update.attributeslists the attribute names a change touched. Match one with~.audit.detailholds JSON, filtered by a key under it.approveris null when no gate held the wave, or when the audit trail has no entry for it.waveis a number.finished,atandreads_seenare times.
No table holds an attribute’s value, because no file in the bucket does.
Gates and approvals
Section titled “Gates and approvals”Each wave’s gate and its approvals are on chant/lifecycle, under op tf-apply. Fetch the branch, then read its gates table:
git fetch origin chant/lifecycle:chant/lifecycle
npx terragucci query gates --where op=tf-applyA pending row is a wave that waited for an approval, and a resolution row names who approved it in resolved_by. The other ledger tables are resources, snapshots, runs, deploys, releases and cuts. They are chant’s own, and chant ledger <table> prints the same rows; the chant query guide describes their columns.
-
Keep reports in a bucket, and run
terragucci auditon a schedule for thehistoryapprovers and theaudittable. -
Give your shell read access to the bucket in the variables Reports lists.
-
From the repo’s root, run
npx terragucci query <table>with the filters you need. Outside the repo, add--bucketand--bucket-prefix. Add--jsonfor the rows as JSON.
The query reads only. Nothing is written to the bucket or to the branch.
The SQL form
Section titled “The SQL form”terragucci query "<statement>", with an SQL statement in place of a table, still runs over the bucket’s tables on the SQLite built into Node.js 22.13 or later. It is deprecated: it prints a notice naming the table read to use instead, and it will be removed.
- CLI reference for the flags and exit codes.
- See every project in one page for the same files as a page.
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.