Skip to content

tfcensus doctor ​

doctor runs terragrunt --version and the --tf-path binary's version command, and compares them with the minimums: terragrunt 1.0.0, terraform 1.5.0 and tofu 1.6.0. It lists the features a found version is too old for. A tool that isn't installed is reported but doesn't fail the run. With --decrypt-with-tofu (config state.decrypt_with_tofu), it also checks the --tofu-path binary.

doctor then loads the credentials of every selected account source and probes each account and region for the inventory layers a scan can use:

text
re      Resource Explorer: an index in the region and a view to search it with
config  AWS Config: a recorder that is recording
cc      Cloud Control: always available, but slow and throttled
native  tfcensus's own enumerators: always available

Without --profile or --org, doctor uses the default AWS credentials (AWS_PROFILE, environment credentials or an instance role). Without --region, it probes the regions that have a Resource Explorer index and the profile's own region. --all-regions probes every region the account has enabled (account:ListRegions). --account and --exclude-account keep or drop account IDs before doctor assumes any role in them.

doctor is read-only: it never creates indexes, views or recorders. Its notes say what an admin could turn on. Results are cached for 24 hours under $XDG_CACHE_HOME/tfcensus/probe; --refresh probes again.

A source whose credentials fail, such as a profile with an expired SSO token, is skipped with a warning. doctor exits 4 when every source fails, and 1 when a tool is older than its minimum.

Usage ​

sh
tfcensus doctor [flags]

Flags ​

FlagDescriptionTypeDefaultValuesConfig keyNotes
--accountkeep only this account ID (repeatable; config accounts.include)string, repeatableaccounts.include
--all-regionsuse every region each account has enabled, from account:ListRegions (config all_regions)boolall_regionsnot with --region
--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
--management-profileprofile that lists the organization's accounts, else the default AWS credentials (config accounts.org.management_profile)stringaccounts.org.management_profile
--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
--profileAWS profile from ~/.aws/config, or a glob such as 'acme-*' (repeatable; config accounts.profiles)string, repeatableaccounts.profiles
--refreshprobe again even when the cached result is freshbool
--regionAWS region (repeatable; config regions)string, repeatable34 values; shell completion lists themregionsnot with --all-regions

The global flags work with every command.

Output formats ​

--format accepts tty, plain, md, json. Without it, the format is tty when stdout is a terminal and plain otherwise. Formats are described on the global flags page.

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.
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 doctor --profile 'acme-*'
tfcensus doctor --profile acme-nonprod --region eu-west-1 --region us-east-1
tfcensus doctor --org --management-profile acme-mgmt --format json