Getting started
This page takes you from an installed binary to a first scan, in four read-only commands. None of them changes anything in AWS or in your repositories.
The outputs below come from tfcensus's own test fixtures, so they match what this release prints. The fixtures are sample repositories named tg-live, tf-fleet and tf-scan, and the AWS account 111111111111 behind the profile acme-nonprod. Use your own paths and profiles.
Before you start
- tfcensus is installed.
- An AWS profile can read the accounts you want to look at. The read-only policy has every action tfcensus calls.
- terragrunt and terraform (or OpenTofu) are on
PATHif your repository uses Terragrunt. The supported versions page lists the oldest versions tfcensus runs.
1. Check the setup
doctor checks the tool versions, loads the credentials of each profile, and probes each account and region for the inventory sources a scan can use:
tfcensus doctor --profile acme-nonprodTOOL PATH VERSION MINIMUM STATUS
terragrunt terragrunt - 1.0.0 not found
terraform terraform - 1.5.0 not found
SOURCE KIND ACCOUNT NAME STATUS
acme-nonprod profile 111111111111 acme-nonprod ok
ACCOUNT REGION RESOURCE EXPLORER CONFIG AGGREGATORS LAYERS
111111111111 eu-central-1 local, default view recording (continuous, all supported) none re, config, cc, native
111111111111 eu-north-1 local, no view no recorder none cc, native
111111111111 eu-west-1 local, default view recording (continuous, all supported) none re, config, cc, native
111111111111 us-east-1 local, default view no recorder none re, cc, native
111111111111 (acme-nonprod): Resource Explorer supports 649 resource types.
111111111111 (acme-nonprod): eu-north-1: the Resource Explorer index has no view, and tfcensus never creates one. An admin can create a default view (`aws resource-explorer-2 create-view`, then `associate-default-view`).
111111111111 (acme-nonprod): eu-north-1: no AWS Config recorder, so the config layer is off here.
111111111111 (acme-nonprod): us-east-1: no AWS Config recorder, so the config layer is off here.The first table lists terragrunt and terraform. Here neither is on PATH, which doctor reports without failing. A plain Terraform repository needs neither for inventory and scan, and a Terragrunt repository needs terragrunt to list its units. The second table says the profile loaded and which account it belongs to. The third shows, per region, whether Resource Explorer and AWS Config are set up, and the layers a scan uses there: re (Resource Explorer), config (AWS Config), cc (Cloud Control) and native (tfcensus's own listers). The notes at the end say what an admin could turn on. doctor never turns anything on itself.
2. List the units
units finds the Terragrunt units and plain Terraform root modules under a path, and shows where each keeps its state and which account and region it manages:
tfcensus units tg-liveREPO UNIT KIND BACKEND LOCK ACCOUNT REGION RESOLUTION WARNINGS
tg-live live/nonprod/eu-west-1/dev/app terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/eu-west-1/dev/app/terraform.tfstate (eu-west-1) lockfile 111111111111 eu-west-1 fast-path 0
tg-live live/nonprod/eu-west-1/dev/db terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/eu-west-1/dev/db/terraform.tfstate (eu-west-1) lockfile 111111111111 eu-west-1 fast-path 0
tg-live live/nonprod/eu-west-1/dev/vpc terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/eu-west-1/dev/vpc/terraform.tfstate (eu-west-1) lockfile 111111111111 eu-west-1 fast-path 0
tg-live live/nonprod/eu-west-1/staging/app terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/eu-west-1/staging/app/terraform.tfstate (eu-west-1) lockfile 111111111111 eu-west-1 fast-path 0
tg-live live/nonprod/eu-west-1/staging/vpc terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/eu-west-1/staging/vpc/terraform.tfstate (eu-west-1) lockfile 111111111111 eu-west-1 fast-path 0
tg-live live/nonprod/us-east-1/global/iam terragrunt s3://acme-tfstate-acme-nonprod/live/nonprod/us-east-1/global/iam/terraform.tfstate (eu-west-1) lockfile 111111111111 us-east-1 fast-path 0
tg-live live/prod/eu-central-1/prod/edge terragrunt s3://acme-tfstate-acme-prod/live/prod/eu-central-1/prod/edge/terraform.tfstate (eu-west-1) lockfile 222222222222 eu-central-1 fast-path 0
tg-live live/prod/eu-central-1/prod/services terragrunt-stack - - - - - 1
tg-live live/prod/eu-west-1/prod/app terragrunt s3://acme-tfstate-acme-prod/live/prod/eu-west-1/prod/app/terraform.tfstate (eu-west-1) lockfile 222222222222 eu-west-1 fast-path 0
tg-live live/prod/eu-west-1/prod/db terragrunt s3://acme-tfstate-acme-prod/live/prod/eu-west-1/prod/db/terraform.tfstate (eu-west-1) both 222222222222 eu-west-1 fast-path 0
tg-live live/prod/eu-west-1/prod/dns terragrunt s3://acme-tfstate-acme-prod/prod/dns/terraform.tfstate (eu-west-1) lockfile 222222222222 eu-west-1 render 1
tg-live live/prod/eu-west-1/prod/legacy terragrunt s3://acme-tfstate-acme-prod/live/prod/eu-west-1/prod/legacy/terraform.tfstate (eu-west-1) lockfile 222222222222 eu-west-1 fast-path 1
tg-live live/prod/eu-west-1/prod/secrets terragrunt - - - - unresolved 0
tg-live live/prod/eu-west-1/prod/vpc terragrunt s3://acme-tfstate-acme-prod/live/prod/eu-west-1/prod/vpc/terraform.tfstate (eu-west-1) lockfile 222222222222 eu-west-1 fast-path 0
tg-live/live/prod/eu-central-1/prod/services: not generated: run with --generate-stacks to list its units
tg-live/live/prod/eu-west-1/prod/dns: resolved by render; the fast path failed: remote_state config key: live/prod/eu-west-1/prod/dns/terragrunt.hcl:15: Error in function call: Call to function "run_cmd" failed: run_cmd: function needs terragrunt render
tg-live/live/prod/eu-west-1/prod/legacy: excluded by terragrunt for: all
tg-live/live/prod/eu-west-1/prod/secrets: unresolved: fast path: remote_state config bucket: live/prod/eu-west-1/prod/secrets/terragrunt.hcl:14: Error in function call: Call to function "run_cmd" failed: run_cmd: function needs terragrunt render; render: render failed: live/prod/eu-west-1/prod/secrets/terragrunt.hcl:14,20-28: Error in function call; Call to function "run_cmd" failed: running command: Failed to execute "false" in live/prod/eu-west-1/prod/secrets
13 units: 11 fast-path, 1 render, 0 static, 1 unresolvedfast-path means tfcensus evaluated the unit's remote_state itself. The dns unit calls run_cmd, which only terragrunt can evaluate, so tfcensus rendered it with terragrunt (render). The secrets unit failed both ways, and the notes under the table say why. The terragrunt-stack row is a stack whose units aren't generated yet: --generate-stacks lists them.
3. Read the state
inventory reads each unit's state from its S3 backend and counts what it manages. It takes no lock, so it is safe to run during an apply, and it prints identifiers and counts, never attribute values:
tfcensus inventory tf-fleetREPO UNIT WORKSPACE STATUS SERIAL VERSION RESOURCES SIZE MODIFIED PROVIDERS
tf-fleet app default ok 7 1.12.2 7 5.0 KiB 2026-11-09 08:30 hashicorp/aws 6.20.0, hashicorp/random 3.7.2
tf-fleet edge default ok 19 1.10.6 (opentofu) 2 1.2 KiB 2026-11-09 08:30 hashicorp/aws
tf-fleet edge staging ok 3 1.10.6 (opentofu) 1 726 B 2026-11-09 08:30 hashicorp/aws
tf-fleet legacy default unsupported 88 0.11.14 - 469 B 2026-11-09 08:30 -
tf-fleet network default ok 42 1.5.7 (terraform) 7 5.3 KiB 2026-11-09 08:30 hashicorp/aws
tf-fleet planned default absent - - - - - -
tf-fleet restricted default error - - - - - -
tf-fleet secure default encrypted 12 - - 236 B 2026-11-09 08:30 -
tf-fleet shared default ok 2 1.11.4 0 181 B 2026-11-09 08:30 -
tf-fleet/legacy: unsupported state format version 3: tfcensus reads version 4 (Terraform 0.12 and later)
tf-fleet/restricted: error: access denied: s3:GetObject on s3://acme-restricted-tfstate/restricted/terraform.tfstate; the backend credentials need s3:GetObject, and kms:Decrypt when the bucket uses SSE-KMS
tf-fleet/restricted: workspaces not listed: access denied: s3:ListBucket on s3://acme-restricted-tfstate/env:/; the backend credentials need s3:ListBucket
tf-fleet/secure: state is encrypted with OpenTofu client-side encryption, so only serial and lineage are readable; --decrypt-with-tofu reads it with tofu show -json in the unit
double-managed aws_security_group account_id=111111111111,id=sg-0123456789abcdef0,region=eu-west-1 by tf-fleet/app (aws_security_group.legacy_web) and tf-fleet/network (aws_security_group.web) (matched on identity)
9 states: 5 ok, 1 absent, 1 encrypted, 1 unsupported, 1 error, 0 skipped; 17 resource instances, 1 double-managedEach workspace of a unit is its own row. The rows that aren't ok show what can go wrong: a unit that has no state yet (absent), a state written by Terraform before 0.12 (unsupported), a state the backend credentials can't read (error), and an OpenTofu state with client-side encryption (encrypted). Each problem is printed under the table with what to do about it. The double-managed line says that two states manage the same security group, which a later apply of one of them would fight over.
4. Find unmanaged resources
scan lists the live resources of each account and region, matches them against the states of the units, and puts each resource in a category:
tfcensus scan tf-scan --config tf-scan/tfcensus.yamlACCOUNT REGION MANAGED DOUBLE-MANAGED UNMANAGED OTHER-IAC AWS-MANAGED DERIVED IGNORED UNDETERMINED COVERAGE
111111111111 global 1 1 2 0 1 0 0 0 50.0%
111111111111 eu-west-1 5 0 3 2 4 1 2 1 62.5%
111111111111 total 6 1 5 2 5 1 2 1 58.3%
Unmanaged (5)
AWS::EC2::SecurityGroup (1)
clickops-debug arn:aws:ec2:eu-west-1:111111111111:security-group/sg-0c11c0b5000000003 owner=alice 40d
AWS::ElasticLoadBalancingV2::ListenerRule (1)
- arn:aws:elasticloadbalancing:eu-west-1:111111111111:listener-rule/app/web/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee - -
AWS::IAM::Role (1)
clickops-admin arn:aws:iam::111111111111:role/clickops-admin created-by=bob 89d
AWS::IAM::User (1)
sandbox-user arn:aws:iam::111111111111:user/sandbox-user owner=sandbox -
AWS::S3::Bucket (1)
acme-growth-experiments arn:aws:s3:::acme-growth-experiments - -
Double-managed (1)
AWS::IAM::Role arn:aws:iam::111111111111:role/acme-shared: tf-scan/iam (aws_iam_role.shared) and tf-scan/iam-dup (aws_iam_role.shared)
CloudFormation stacks (2)
billing: 2 resources
billing-AlarmsStack-1ABCDEF (nested in billing): 1 resource
Undetermined (1)
no type mapping for AWS::EC2::KeyPair: 1
warning: AWS::Lambda::Function arn:aws:lambda:eu-west-1:111111111111:function:acme-api is in a state and in CloudFormation stack billing as Api
warning: rule "growth-trial" is past its expires date and no longer matches
23 resources: 6 managed, 1 double-managed, 5 unmanaged, 2 other-iac, 5 aws-managed, 1 derived, 2 ignored, 1 undetermined; coverage 58.3%The table counts each category per account and region:
managed: one state manages the resource.double-managed: more than one does.unmanaged: no state manages it and no ownership rule explains it. These are the findings to look at: click-ops, leftovers and resources someone forgot to import.other-iac,aws-managed,derivedandignored: no state manages it, and an ownership rule says why, such as a CloudFormation stack, the default VPC or a child that AWS created with its parent. The rule packs list the built-in rules.undetermined: tfcensus has no mapping for the type, so it can't tell. The type coverage page lists the mapped types.
Coverage is the share of managed resources among managed, double-managed and unmanaged ones. Every finding carries a rule and a reason, which --format json prints, and the rule IDs page explains each rule.
Next steps
- Gate CI on new unmanaged resources with
tfcensus scan --fail-on unmanaged, which exits 3 when it finds one (exit codes). - Check the state buckets and lock tables with
tfcensus audit backend(audit checks). - Put your profiles, regions and rules in a config file:
tfcensus config initwrites a commented file to start from (configuration). - Every command, flag and output format is in the CLI reference.