Skip to content

tfcensus notify ​

notify reads the JSON that scan, drift and audit print with --format json and publishes it. It never collects anything itself.

text
slack                 one message per report to an incoming webhook, with counts and the top
                      findings; sent only when there is something to report (notify.slack.when)
github-issues         one issue per scope: per unit for drift, per account for scan and audit.
                      A re-run updates the body only when it changed, and closes the issue when
                      the run covered the scope and found nothing. notify.github_issues.max_open
                      caps new issues
github-pr-comment     one comment per report on a GitHub pull request, edited in place. The
                      pull request comes from GITHUB_EVENT_PATH; a report with nothing open
                      turns the comment into "Nothing to report"
bitbucket-pr-comment  one comment per report on a Bitbucket Cloud pull request, edited in place
file                  tfcensus-<kind>.md and .json in notify.file.dir, rewritten only on change

Every issue body and comment starts with a hidden marker that names the report kind, the scope and a hash of the body, so runs find their own issues and skip unchanged ones. Only issues with the tfcensus label are read.

Secrets come from the environment only: the variables named by notify.slack.webhook_env, notify.github_issues.token_env, notify.github_pr_comment.token_env and notify.bitbucket_pr_comment.token_env. They are never logged; -vvv shows request headers with Authorization redacted.

--dry-run-notify reads the existing issues and comments with GET requests and prints what would change, writing nothing.

Exit codes: 0 when every notifier succeeded, 2 when no notifier is enabled, a notifier is unknown or not configured, or a --from file is not a tfcensus report, 4 when every failure was a refused token, and 1 for any other failure.

Usage ​

sh
tfcensus notify [flags]

Flags ​

FlagDescriptionTypeDefaultValuesConfig keyNotes
--dry-run-notifyprint what would change; read with GET only and write nothingbool
--fromscan, drift or audit JSON file (repeatable)string, repeatable
--notifynotifiers to run instead of notify.enabled: slack, github-issues, github-pr-comment, bitbucket-pr-comment or filelist, repeatableslack: one message per report to an incoming webhook
github-issues: one GitHub issue per scope
github-pr-comment: one comment per report on a GitHub pull request
bitbucket-pr-comment: one comment per report on one pull request
file: tfcensus-<kind>.md and .json files

The global flags work with every command.

Output formats ​

--format accepts tty, plain, 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 drift --format json > drift.json; tfcensus notify --from drift.json --notify github-issues
tfcensus notify --from scan.json --from audit.json --dry-run-notify
tfcensus notify --from drift.json --notify github-pr-comment   # in a pull_request workflow
GITHUB_TOKEN=... tfcensus notify --from drift.json --notify github-issues,slack