Skip to content

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 ​

sh
tfcensus whois <arn|id>... [flags]

Arguments ​

ArgumentRequiredRepeatable
arn|id>yesyes

Flags ​

FlagDescriptionTypeDefaultValuesConfig keyNotes
--accountkeep only this account ID (repeatable; config accounts.include)string, repeatableaccounts.include
--concurrencystates read at the same timeint16
--decrypt-with-tofuread OpenTofu encrypted state with tofu init and tofu show -json in the unit, which downloads and runs its providers (config state.decrypt_with_tofu)boolstate.decrypt_with_tofu
--exclude-accountdrop this account ID (repeatable; config accounts.exclude)string, repeatableaccounts.exclude
--fail-onexit 3 when answers are in these categories: unmanaged or double-managedlist, repeatableunmanaged: no state manages it
double-managed: more than one state manages it
--filterterragrunt filter expression, passed to terragrunt find unchanged (repeatable)string, repeatable
--generate-stacksrun terragrunt stack generate first, so units in stacks are listed (config discovery.generate_stacks)booldiscovery.generate_stacks
--indexread the state index from this file (from inventory --save-index) instead of reading statesstringnot with --repo
--livelist an unmanaged resource's type live so the rules see its tags (false with --index)booltrue
--management-profileprofile that lists the organization's accounts, else the default AWS credentials (config accounts.org.management_profile)stringaccounts.org.management_profile
--md-max-charscut Markdown output to this many characters at a row or section boundary; 0 means no limitint60000
--min-countanswers --fail-on needs before it exits 3int1
--orglist the accounts of the AWS organization and assume --org-role in each (config accounts.org.enabled)boolaccounts.org.enabled
--org-rolerole assumed in each member account (config accounts.org.role)stringOrganizationAccountAccessRoleaccounts.org.role
--outalso write the report to a file as format=path (repeatable); format is one of plain, md, json or sarifstring, repeatableplain: table without color
md: Markdown
json: JSON envelope for scripts
sarif: SARIF 2.1.0 for code scanning
--profileAWS profile from ~/.aws/config, or a glob such as 'acme-*' (repeatable; config accounts.profiles)string, repeatableaccounts.profiles
--regionAWS region (repeatable; config regions)string, repeatable34 values; shell completion lists themregions
--renderwhen to use terragrunt render: auto, always or never (config discovery.render)stringautoauto: parse terragrunt.hcl, render the units it can't resolve
always: run terragrunt render for every unit
never: never run terragrunt render
discovery.render
--reporepository to discover units in (repeatable; config discovery.roots, else the working directory)string, repeatablenot with --index
--rulesYAML file with more ownership rules under rules: (repeatable)string, repeatable
--stdinread more ARNs or ids from stdin, one per linebool
--typeTF resource types to look in, such as aws_security_grouplist, 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:

ValueMatches
unmanagedno state manages it
double-managedmore than one state manages it

Exit codes ​

CodeMeaning
0The command finished. With --fail-on, nothing matched.
1The command failed: a read, a write, a child process or a check failed.
2Wrong usage: an unknown command or flag, a bad value or argument, an invalid config file, or a prompt with no terminal.
3A --fail-on gate matched. The report is still written.
4Credentials were missing or rejected for every source the command needed.
130Interrupted by Ctrl-C (SIGINT) or a cancelled context.

All codes are listed on the exit codes page.

Examples ​

sh
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