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:
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 availableWithout --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
tfcensus doctor [flags]Flags
| Flag | Description | Type | Default | Values | Config key | Notes |
|---|---|---|---|---|---|---|
--account | keep only this account ID (repeatable; config accounts.include) | string, repeatable | accounts.include | |||
--all-regions | use every region each account has enabled, from account:ListRegions (config all_regions) | bool | all_regions | not with --region | ||
--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 | |||
--management-profile | profile that lists the organization's accounts, else the default AWS credentials (config accounts.org.management_profile) | string | accounts.org.management_profile | |||
--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 | ||
--profile | AWS profile from ~/.aws/config, or a glob such as 'acme-*' (repeatable; config accounts.profiles) | string, repeatable | accounts.profiles | |||
--refresh | probe again even when the cached result is fresh | bool | ||||
--region | AWS region (repeatable; config regions) | string, repeatable | 34 values; shell completion lists them | regions | not 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
| 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. |
| 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 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