Skip to content

Configuration ​

tfcensus reads its settings in layers, and a later layer wins: the defaults, the user file ($XDG_CONFIG_HOME/tfcensus/config.yaml), the project file (.tfcensus.yaml, found by walking up from the working directory), environment variables and flags. tfcensus config show --sources prints each value and its layer, and tfcensus config init writes the commented template at the end of this page. Files are checked against config-v1.json.

A key's environment variable is TFCENSUS_ followed by the key in upper case, with dots and dashes as underscores. Only scalars and string lists (comma-separated) can be set this way. See environment variables.

schema_version ​

TypeDefaultAllowedEnvironmentFlag
integer11TFCENSUS_SCHEMA_VERSION

Config file format version.

binaries ​

binaries.terragrunt ​

TypeDefaultAllowedEnvironmentFlag
stringterragruntTFCENSUS_BINARIES_TERRAGRUNT--tg-path

terragrunt binary, a name on PATH or a path.

binaries.terraform ​

TypeDefaultAllowedEnvironmentFlag
stringterraformTFCENSUS_BINARIES_TERRAFORM--tf-path

terraform or tofu binary, passed to terragrunt as --tf-path.

binaries.tofu ​

TypeDefaultAllowedEnvironmentFlag
stringtofuTFCENSUS_BINARIES_TOFU--tofu-path

tofu binary that reads OpenTofu encrypted state when state.decrypt_with_tofu is on.

discovery ​

discovery.roots ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_DISCOVERY_ROOTS

Directories to discover units in.

discovery.generate_stacks ​

TypeDefaultAllowedEnvironmentFlag
booleanfalseTFCENSUS_DISCOVERY_GENERATE_STACKS--generate-stacks

Run terragrunt stack generate before discovery.

discovery.render ​

TypeDefaultAllowedEnvironmentFlag
stringautoauto, always, neverTFCENSUS_DISCOVERY_RENDER--render

Use terragrunt render: auto, always or never (fast path only).

accounts ​

accounts.profiles ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_ACCOUNTS_PROFILES--profile

AWS profile globs from ~/.aws/config.

accounts.include ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_ACCOUNTS_INCLUDE--account

Account IDs that doctor, scan and whois list resources in. Empty means every loaded account.

accounts.exclude ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_ACCOUNTS_EXCLUDE--exclude-account

Account IDs that doctor, scan and whois skip. scan and whois still read state with their credentials.

accounts.org.enabled ​

TypeDefaultAllowedEnvironmentFlag
booleanfalseTFCENSUS_ACCOUNTS_ORG_ENABLED--org

List the accounts of the organization and assume a role in each.

accounts.org.management_profile ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_ACCOUNTS_ORG_MANAGEMENT_PROFILE--management-profile

Profile that lists the accounts. Empty means the default AWS credentials.

accounts.org.role ​

TypeDefaultAllowedEnvironmentFlag
stringOrganizationAccountAccessRoleTFCENSUS_ACCOUNTS_ORG_ROLE--org-role

Role assumed in each member account.

accounts.org.ou_roles ​

TypeDefaultAllowedEnvironmentFlag
map of string{}

OU or root ID to the role assumed in the accounts directly under it, instead of role.

accounts.map ​

TypeDefaultAllowedEnvironmentFlag
map of object{}

Account ID to profile and display name, for when profile names don't match accounts.

Each entry has these fields:

FieldTypeDescription
profilestringAWS profile whose credentials reach the account.
namestringName shown for the account in reports.

accounts.aggregator.profile ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_ACCOUNTS_AGGREGATOR_PROFILE

AWS profile for the aggregator's account. Empty means the default credentials.

accounts.aggregator.name ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_ACCOUNTS_AGGREGATOR_NAME

Name of the AWS Config aggregator. Empty turns the aggregator off.

accounts.aggregator.region ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_ACCOUNTS_AGGREGATOR_REGION

Region the aggregator is in.

state ​

state.decrypt_with_tofu ​

TypeDefaultAllowedEnvironmentFlag
booleanfalseTFCENSUS_STATE_DECRYPT_WITH_TOFU--decrypt-with-tofu

Read OpenTofu encrypted state with tofu init and tofu show -json in the unit, which downloads and runs its providers. The key configuration comes from the unit or TF_ENCRYPTION.

regions ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_REGIONS--region

Regions to scan. Empty means the regions found in the units' backends and providers.

all_regions ​

TypeDefaultAllowedEnvironmentFlag
booleanfalseTFCENSUS_ALL_REGIONS--all-regions

Use every region each account has enabled (account:ListRegions) instead of regions.

scan ​

scan.layers ​

TypeDefaultAllowedEnvironmentFlag
stringautoTFCENSUS_SCAN_LAYERS--layers

Inventory layers: auto, or a comma-separated list of re, config, cc and native.

scan.cloudcontrol_types ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_SCAN_CLOUDCONTROL_TYPES

CloudFormation types listed through Cloud Control, on top of the types only Cloud Control lists (the VPC Lattice resource gateways, resource configurations and service network associations).

scan.cloudformation ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_CLOUDFORMATION

List CloudFormation stack resources; a resource a stack lists and no state manages is other-iac.

scan.packs.aws-defaults ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_PACKS_AWS_DEFAULTS

Run the pack for resources AWS creates in every account and region, such as the default VPC.

scan.packs.aws-service ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_PACKS_AWS_SERVICE

Run the pack for resources that AWS services, IAM Identity Center, Control Tower, StackSets and CDK bootstrap create.

scan.packs.other-iac ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_PACKS_OTHER_IAC

Run the pack for resources another IaC tool or a Kubernetes controller manages, found by its tags.

scan.packs.derived ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_PACKS_DERIVED

Run the pack for resources AWS creates as children of another resource.

scan.packs.ephemeral ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_SCAN_PACKS_EPHEMERAL

Run the pack for short-lived or by-product resources that nobody manages on purpose.

scan.never_hide ​

TypeDefaultAllowedEnvironmentFlag
list of string[]other-iac, aws-managed, derived, ignoredTFCENSUS_SCAN_NEVER_HIDE

Categories that user rules can't give to guarded resources (IAM users).

scan.external_dns.txt_prefix ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_SCAN_EXTERNAL_DNS_TXT_PREFIX

external-dns --txt-prefix; may hold %{record_type}. Empty tries no prefix, then external-dns-.

scan.external_dns.txt_suffix ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_SCAN_EXTERNAL_DNS_TXT_SUFFIX

external-dns --txt-suffix; may hold %{record_type}.

rules ​

TypeDefaultAllowedEnvironmentFlag
list of object[]

Ownership rules, tried in order after the built-in packs. The first rule that matches an unmanaged resource sets its category.

Each entry has these fields:

FieldTypeDescription
namestringRule name, shown in findings as user/<name>.
categorystringCategory of the resources the rule matches.
ownerstringWho owns the matched resources, such as datadog.
matchstringCEL expression that returns a bool, over resource and unit.
reasonstringWhy the matched resources aren't unmanaged.
expiresstringLast day the rule applies, as a quoted "YYYY-MM-DD" date (UTC). After it the rule stops matching and scan warns.

audit ​

audit.policy.min_terraform_version ​

TypeDefaultAllowedEnvironmentFlag
string1.10TFCENSUS_AUDIT_POLICY_MIN_TERRAFORM_VERSION

FL-TFVER flags states written by an older terraform or tofu.

audit.policy.min_provider_versions ​

TypeDefaultAllowedEnvironmentFlag
map of string{}

FL-PROV: provider source (hashicorp/aws) to the oldest version allowed in .terraform.lock.hcl.

audit.policy.noncurrent_days ​

TypeDefaultAllowedEnvironmentFlag
integer30at least 0TFCENSUS_AUDIT_POLICY_NONCURRENT_DAYS

S3-LC: noncurrent state versions must be kept at least this many days.

audit.policy.stale_lock_hours ​

TypeDefaultAllowedEnvironmentFlag
integer24at least 0TFCENSUS_AUDIT_POLICY_STALE_LOCK_HOURS

LK-STALE flags locks older than this.

audit.policy.max_state_mb ​

TypeDefaultAllowedEnvironmentFlag
number20at least 0TFCENSUS_AUDIT_POLICY_MAX_STATE_MB

FL-SIZE flags states larger than this many MiB.

audit.discover_patterns ​

TypeDefaultAllowedEnvironmentFlag
list of string["*tfstate*","*terraform-state*","*tf-state*"]TFCENSUS_AUDIT_DISCOVER_PATTERNS--discover-pattern

Bucket name globs that audit backend --discover audits, matched against every bucket of each account.

audit.suppress ​

TypeDefaultAllowedEnvironmentFlag
list of object[]

Suppressions. A finding matching every set field of an entry is suppressed until expires.

Each entry has these fields:

FieldTypeDescription
checkstringCheck ID or glob, such as S3-MFA or LK-*.
bucketstringBucket name glob.
unitstringUnit glob, repo/path.
keystringState key or lock table glob.
reasonstringWhy the finding is accepted.
expiresstringLast day the suppression applies, as a quoted "YYYY-MM-DD" date (UTC). After it the finding comes back with a warning.

drift ​

drift.mode ​

TypeDefaultAllowedEnvironmentFlag
stringrefresh-onlyrefresh-only, fullTFCENSUS_DRIFT_MODE--mode

refresh-only reports drift; full also tells drift the plan reverts from drift it keeps.

drift.collapse ​

TypeDefaultAllowedEnvironmentFlag
stringshapeshape, strict, noneTFCENSUS_DRIFT_COLLAPSE--collapse

How identical changes in several units become one group.

drift.never_hide ​

TypeDefaultAllowedEnvironmentFlag
list of string["delete","replace"]create, update, delete, replaceTFCENSUS_DRIFT_NEVER_HIDE

Drift actions that no noise rule can hide.

drift.noise ​

TypeDefaultAllowedEnvironmentFlag
list of object[]

Noise rules, tried in order. A rule hides the matching attribute changes, or the whole change when it has no attribute.

Each entry has these fields:

FieldTypeDescription
presetstringA built-in rule. A preset entry takes no other key.
namestringRule name, shown on hidden drift as user/<name>.
unitstringUnit path glob; * matches any characters, / included.
typestringResource type glob, such as aws_s3_*.
addressstringResource address glob, such as module.tags.*.
attributestringAttribute path such as tags_all or ingress[*].cidr_blocks. It also matches everything below it.
actionstringDrift action.
reasonstringWhy the drift is noise. Required for rules.
expiresstringLast day the rule applies, as a quoted "YYYY-MM-DD" date (UTC). After it the rule stops hiding drift and drift warns.

notify ​

notify.enabled ​

TypeDefaultAllowedEnvironmentFlag
list of string[]slack, github-issues, github-pr-comment, bitbucket-pr-comment, fileTFCENSUS_NOTIFY_ENABLED

Notifiers tfcensus notify runs when --notify isn't given.

notify.categories ​

TypeDefaultAllowedEnvironmentFlag
list of string["double-managed","unmanaged"]double-managed, unmanaged, undeterminedTFCENSUS_NOTIFY_CATEGORIES

Scan categories the notifiers report.

notify.min_severity ​

TypeDefaultAllowedEnvironmentFlag
stringlowinfo, low, medium, highTFCENSUS_NOTIFY_MIN_SEVERITY

Lowest backend audit severity the notifiers report.

notify.top ​

TypeDefaultAllowedEnvironmentFlag
integer10at least 1TFCENSUS_NOTIFY_TOP

Findings listed in a Slack message.

notify.slack.webhook_env ​

TypeDefaultAllowedEnvironmentFlag
stringSLACK_WEBHOOK_URLpattern ^[A-Za-z_][A-Za-z0-9_]*$TFCENSUS_NOTIFY_SLACK_WEBHOOK_ENV

Environment variable that holds the incoming webhook URL.

notify.slack.when ​

TypeDefaultAllowedEnvironmentFlag
stringfindingsfindings, alwaysTFCENSUS_NOTIFY_SLACK_WHEN

findings sends only when there is something to report; always sends every run.

TypeDefaultAllowedEnvironmentFlag
string""pattern ^(https://.*)?$TFCENSUS_NOTIFY_SLACK_LINK

URL of the full report, such as a CI artifact, shown in the message.

notify.github_issues.repo ​

TypeDefaultAllowedEnvironmentFlag
string""pattern ^([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)?$TFCENSUS_NOTIFY_GITHUB_ISSUES_REPO

owner/name. Empty means GITHUB_REPOSITORY.

notify.github_issues.api_url ​

TypeDefaultAllowedEnvironmentFlag
string""pattern ^(https?://.*)?$TFCENSUS_NOTIFY_GITHUB_ISSUES_API_URL

REST API base URL. Empty means GITHUB_API_URL, else https://api.github.com.

notify.github_issues.token_env ​

TypeDefaultAllowedEnvironmentFlag
stringGITHUB_TOKENpattern ^[A-Za-z_][A-Za-z0-9_]*$TFCENSUS_NOTIFY_GITHUB_ISSUES_TOKEN_ENV

Environment variable that holds the token (issues: write).

notify.github_issues.labels ​

TypeDefaultAllowedEnvironmentFlag
list of string[]TFCENSUS_NOTIFY_GITHUB_ISSUES_LABELS

Labels added to new issues, besides tfcensus and tfcensus:<kind>.

notify.github_issues.max_open ​

TypeDefaultAllowedEnvironmentFlag
integer10at least 1TFCENSUS_NOTIFY_GITHUB_ISSUES_MAX_OPEN

Most open issues per report kind. Further scopes are listed in the run output and the summary issue.

notify.github_issues.close_resolved ​

TypeDefaultAllowedEnvironmentFlag
booleantrueTFCENSUS_NOTIFY_GITHUB_ISSUES_CLOSE_RESOLVED

Close an issue when a run covers its scope and finds nothing.

notify.github_issues.summary ​

TypeDefaultAllowedEnvironmentFlag
booleanfalseTFCENSUS_NOTIFY_GITHUB_ISSUES_SUMMARY

Keep one summary issue per report kind.

notify.github_pr_comment.repo ​

TypeDefaultAllowedEnvironmentFlag
string""pattern ^([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)?$TFCENSUS_NOTIFY_GITHUB_PR_COMMENT_REPO

owner/name. Empty means GITHUB_REPOSITORY.

notify.github_pr_comment.api_url ​

TypeDefaultAllowedEnvironmentFlag
string""pattern ^(https?://.*)?$TFCENSUS_NOTIFY_GITHUB_PR_COMMENT_API_URL

REST API base URL. Empty means GITHUB_API_URL, else https://api.github.com.

notify.github_pr_comment.pull_request ​

TypeDefaultAllowedEnvironmentFlag
integer0at least 0TFCENSUS_NOTIFY_GITHUB_PR_COMMENT_PULL_REQUEST

Pull request number. 0 means the pull request of the GITHUB_EVENT_PATH event.

notify.github_pr_comment.token_env ​

TypeDefaultAllowedEnvironmentFlag
stringGITHUB_TOKENpattern ^[A-Za-z_][A-Za-z0-9_]*$TFCENSUS_NOTIFY_GITHUB_PR_COMMENT_TOKEN_ENV

Environment variable that holds the token (pull-requests: write).

notify.bitbucket_pr_comment.workspace ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_WORKSPACE

Workspace. Empty means BITBUCKET_WORKSPACE.

notify.bitbucket_pr_comment.repo ​

TypeDefaultAllowedEnvironmentFlag
string""TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_REPO

Repository slug. Empty means BITBUCKET_REPO_SLUG.

notify.bitbucket_pr_comment.pull_request ​

TypeDefaultAllowedEnvironmentFlag
integer0at least 0TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_PULL_REQUEST

Pull request ID. 0 means BITBUCKET_PR_ID.

notify.bitbucket_pr_comment.api_url ​

TypeDefaultAllowedEnvironmentFlag
stringhttps://api.bitbucket.org/2.0pattern ^https?://TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_API_URL

REST API base URL.

notify.bitbucket_pr_comment.token_env ​

TypeDefaultAllowedEnvironmentFlag
stringBITBUCKET_TOKENpattern ^[A-Za-z_][A-Za-z0-9_]*$TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_TOKEN_ENV

Environment variable that holds an access token or API token.

notify.bitbucket_pr_comment.email_env ​

TypeDefaultAllowedEnvironmentFlag
string""pattern ^([A-Za-z_][A-Za-z0-9_]*)?$TFCENSUS_NOTIFY_BITBUCKET_PR_COMMENT_EMAIL_ENV

Environment variable that holds the Atlassian account email. Set it to send an API token with basic auth; empty sends the token as a bearer token.

notify.file.dir ​

TypeDefaultAllowedEnvironmentFlag
string.TFCENSUS_NOTIFY_FILE_DIR

Directory for tfcensus-<kind>.md and .json.

notify.file.formats ​

TypeDefaultAllowedEnvironmentFlag
list of string["md","json"]md, jsonTFCENSUS_NOTIFY_FILE_FORMATS

Files to write.

cache ​

cache.ttl ​

TypeDefaultAllowedEnvironmentFlag
string1hpattern ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$TFCENSUS_CACHE_TTL

How long cached inventory stays fresh, as a Go duration such as 1h.

Template ​

tfcensus config init writes this file:

yaml
# tfcensus configuration, written by 'tfcensus config init'.
# Each key below is commented out and shows its default. Uncomment a key to change it.
# Later layers win: defaults < user file < project file < env (TFCENSUS_*) < flags.
# 'tfcensus config show --sources' prints every effective value and where it came from, and
# 'tfcensus config validate' checks this file. Unknown keys are errors. Credentials never go here.
schema_version: 1
#
# binaries:
#   terragrunt: terragrunt         # a name on PATH or a path
#   terraform: terraform           # terraform or tofu, passed to terragrunt as --tf-path
#   tofu: tofu                     # reads OpenTofu encrypted state when state.decrypt_with_tofu is on
#
# discovery:
#   roots: []                      # directories to discover units in
#   generate_stacks: false         # run terragrunt stack generate before discovery
#   render: auto                   # auto, always or never
#
# accounts:
#   profiles: []                   # AWS profile globs from ~/.aws/config, for example ["acme-*"]
#   include: []                    # account IDs doctor, scan and whois list; empty means all
#   exclude: []                    # account IDs doctor, scan and whois skip
#   org:
#     enabled: false               # list the organization's accounts and assume a role in each
#     management_profile: ""       # profile that lists the accounts; empty means the default credentials
#     role: OrganizationAccountAccessRole
#     ou_roles: {}                 # OU or root ID to the role used for the accounts directly under it
#   map: {}                        # account ID to profile and name, for example {"111111111111": {profile: acme-nonprod, name: acme-nonprod}}
#   aggregator:                    # AWS Config aggregator
#     profile: ""
#     name: ""
#     region: ""
#
# state:
#   decrypt_with_tofu: false       # run tofu init and tofu show -json in units whose state is encrypted
#
# regions: []                      # empty means the regions in the units' backends and providers
# all_regions: false               # every region each account has enabled, instead of regions
#
# scan:
#   layers: auto                   # auto, or a comma-separated list of re, config, cc and native
#   cloudcontrol_types: []         # more types listed through Cloud Control (VPC Lattice is always)
#   cloudformation: true           # list stack resources; what a stack lists and no state manages is other-iac
#   packs:                         # built-in ownership rule packs
#     aws-defaults: true
#     aws-service: true
#     other-iac: true
#     derived: true
#     ephemeral: true
#   never_hide: []                 # categories user rules can't give to IAM users
#   external_dns:                  # TXT registry settings of your external-dns deployments
#     txt_prefix: ""               # --txt-prefix; empty tries no prefix, then external-dns-
#     txt_suffix: ""               # --txt-suffix
#
# rules: []                        # ownership rules, see https://tfcensus.sasskovacs.dev/guides/rules
#
# audit:
#   policy:
#     min_terraform_version: "1.10"  # FL-TFVER
#     min_provider_versions: {}    # FL-PROV, for example {hashicorp/aws: "5.0.0"}
#     noncurrent_days: 30          # S3-LC
#     stale_lock_hours: 24         # LK-STALE
#     max_state_mb: 20             # FL-SIZE
#   discover_patterns:             # bucket globs for audit backend --discover
#     - '*tfstate*'
#     - '*terraform-state*'
#     - '*tf-state*'
#   suppress: []                   # accepted findings, each with reason and an optional expires date
#
# drift:
#   mode: refresh-only             # refresh-only or full
#   collapse: shape                # shape, strict or none
#   never_hide:                    # drift actions no noise rule can hide
#     - delete
#     - replace
#   noise: []                      # noise rules or presets, for example [{preset: aws-tags-all}]
#
# notify:
#   enabled: []                    # slack, github-issues, github-pr-comment, bitbucket-pr-comment, file
#   categories:
#     - double-managed
#     - unmanaged
#   min_severity: low              # info, low, medium or high
#   top: 10                        # findings listed in a Slack message, 1 to 50
#   slack:
#     webhook_env: SLACK_WEBHOOK_URL
#     when: findings               # findings or always
#     link: ""                     # URL of the full report, shown in the message
#   github_issues:
#     repo: ""                     # owner/name; empty means GITHUB_REPOSITORY
#     api_url: ""                  # empty means GITHUB_API_URL, else https://api.github.com
#     token_env: GITHUB_TOKEN
#     labels: []
#     max_open: 10                 # open issues per report kind
#     close_resolved: true
#     summary: false               # keep one summary issue per report kind
#   github_pr_comment:
#     repo: ""                     # owner/name; empty means GITHUB_REPOSITORY
#     api_url: ""
#     pull_request: 0              # 0 means the pull request of the GITHUB_EVENT_PATH event
#     token_env: GITHUB_TOKEN
#   bitbucket_pr_comment:
#     workspace: ""                # empty means BITBUCKET_WORKSPACE
#     repo: ""                     # empty means BITBUCKET_REPO_SLUG
#     pull_request: 0              # 0 means BITBUCKET_PR_ID
#     api_url: https://api.bitbucket.org/2.0
#     token_env: BITBUCKET_TOKEN
#     email_env: ""                # set it to send an API token with basic auth
#   file:
#     dir: .
#     formats:
#       - md
#       - json
#
# cache:
#   ttl: 1h                        # how long cached inventory stays fresh