tfcensus whois
whois looks each ARN or TF resource id up in the state of every discovered unit, with the match keys scan uses (identity, then ARN, then id), and prints the units, addresses, accounts and regions that manage it, and the key that matched. More than one state means double-managed.
An ARN whose type the typemap maps is matched like a live resource; any other ARN, and a bare id, is looked up across every type. --type narrows the lookup to TF types.
When no state manages the resource, the ownership rules explain why (other-iac, aws-managed, ignored or unmanaged). Without --index, whois lists the resource's type in its account and region through the scan inventory layers, so the rules see its tags and relations. With --index the run stays offline and the rules see only what the ARN gives; --live lists anyway. An account that --account or --exclude-account leaves out is never listed, so its answers stay offline.
--index reads an index written by tfcensus inventory --save-index instead of reading every state.
The exit code is 3 when --fail-on finds at least --min-count answers in its categories, 1 when a state read or a layer failed, 4 when every failure was a credential problem, and 0 otherwise.
Usage
tfcensus whois <arn|id>... [flags]Arguments
| Argument | Required | Repeatable |
|---|---|---|
arn|id> | yes | yes |
Flags
| Flag | Description | Type | Default | Values | Config key | Notes |
|---|---|---|---|---|---|---|
--account | keep only this account ID (repeatable; config accounts.include) | string, repeatable | accounts.include | |||
--concurrency | states read at the same time | int | 16 | |||
--decrypt-with-tofu | read OpenTofu encrypted state with tofu init and tofu show -json in the unit, which downloads and runs its providers (config state.decrypt_with_tofu) | bool | state.decrypt_with_tofu | |||
--exclude-account | drop this account ID (repeatable; config accounts.exclude) | string, repeatable | accounts.exclude | |||
--fail-on | exit 3 when answers are in these categories: unmanaged or double-managed | list, repeatable | unmanaged: no state manages itdouble-managed: more than one state manages it | |||
--filter | terragrunt filter expression, passed to terragrunt find unchanged (repeatable) | string, repeatable | ||||
--generate-stacks | run terragrunt stack generate first, so units in stacks are listed (config discovery.generate_stacks) | bool | discovery.generate_stacks | |||
--index | read the state index from this file (from inventory --save-index) instead of reading states | string | not with --repo | |||
--live | list an unmanaged resource's type live so the rules see its tags (false with --index) | bool | true | |||
--management-profile | profile that lists the organization's accounts, else the default AWS credentials (config accounts.org.management_profile) | string | accounts.org.management_profile | |||
--md-max-chars | cut Markdown output to this many characters at a row or section boundary; 0 means no limit | int | 60000 | |||
--min-count | answers --fail-on needs before it exits 3 | int | 1 | |||
--org | list the accounts of the AWS organization and assume --org-role in each (config accounts.org.enabled) | bool | accounts.org.enabled | |||
--org-role | role assumed in each member account (config accounts.org.role) | string | OrganizationAccountAccessRole | accounts.org.role | ||
--out | also write the report to a file as format=path (repeatable); format is one of plain, md, json or sarif | string, repeatable | plain: table without colormd: Markdownjson: JSON envelope for scriptssarif: SARIF 2.1.0 for code scanning | |||
--profile | AWS profile from ~/.aws/config, or a glob such as 'acme-*' (repeatable; config accounts.profiles) | string, repeatable | accounts.profiles | |||
--region | AWS region (repeatable; config regions) | string, repeatable | 34 values; shell completion lists them | regions | ||
--render | when to use terragrunt render: auto, always or never (config discovery.render) | string | auto | auto: parse terragrunt.hcl, render the units it can't resolvealways: run terragrunt render for every unitnever: never run terragrunt render | discovery.render | |
--repo | repository to discover units in (repeatable; config discovery.roots, else the working directory) | string, repeatable | not with --index | |||
--rules | YAML file with more ownership rules under rules: (repeatable) | string, repeatable | ||||
--stdin | read more ARNs or ids from stdin, one per line | bool | ||||
--type | TF resource types to look in, such as aws_security_group | list, repeatable |
The global flags work with every command.
Output formats
--format accepts tty, plain, md, json, sarif. Without it, the format is tty when stdout is a terminal and plain otherwise. Formats are described on the global flags page.
Fail-on values
--fail-on makes the command exit 3 when the report has a match:
| Value | Matches |
|---|---|
unmanaged | no state manages it |
double-managed | more than one state manages it |
Exit codes
| Code | Meaning |
|---|---|
| 0 | The command finished. With --fail-on, nothing matched. |
| 1 | The command failed: a read, a write, a child process or a check failed. |
| 2 | Wrong usage: an unknown command or flag, a bad value or argument, an invalid config file, or a prompt with no terminal. |
| 3 | A --fail-on gate matched. The report is still written. |
| 4 | Credentials were missing or rejected for every source the command needed. |
| 130 | Interrupted by Ctrl-C (SIGINT) or a cancelled context. |
All codes are listed on the exit codes page.
Examples
tfcensus whois arn:aws:iam::111111111111:role/app --repo ~/src/infra/acme-live
tfcensus whois --index index.json.zst sg-0123456789abcdef0 --type aws_security_group
jq -r '.data.findings[].arn // empty' scan.json | tfcensus whois --stdin --index index.json.zst
tfcensus whois --index index.json.zst --fail-on double-managed arn:aws:s3:::acme-assets