tf-audit
Terraform Configuration Auditor & Security Scanner — 55+ rules for security misconfigurations, naming conventions, module quality, and best practices across AWS, Azure, and GCP.
Features
- 20 Security Rules — S3 encryption, public databases, open security groups, IAM wildcards, Key Vault misconfigs
- 8 Naming Convention Rules — snake_case enforcement for resources, variables, outputs, modules
- 12 Module Quality Rules — Version pinning, variable descriptions, type constraints, backend config
- 15+ Best Practice Rules — Tagging, sensitive flags, .gitignore, file organization
- Multi-Cloud — AWS, Azure, and GCP resource support
- Multiple Export Formats — Terminal (Rich), JSON, HTML, SARIF
- CI/CD Integration —
--fail-onflag for pipeline quality gates - Demo Mode — Try instantly with intentionally insecure Terraform files
Installation
pip install -e .
Quick Start
# Scan a Terraform directory
tf-audit scan ./infrastructure
# Run the demo
tf-audit demo
# Verbose output with fix suggestions
tf-audit scan . --verbose
# Export as JSON for CI/CD
tf-audit scan . --format json --output report.json
# Fail CI if critical issues found
tf-audit scan . --fail-on critical
# List all rules
tf-audit rules
Commands
| Command | Description |
|---|---|
tf-audit scan <path> |
Scan .tf files for issues |
tf-audit demo |
Run demo with intentionally insecure Terraform |
tf-audit rules |
List all 55+ audit rules |
Scan Options
| Option | Description |
|---|---|
--verbose / -v |
Show fix suggestions for each issue |
--format / -f |
Output format: terminal, json, html, sarif |
--output / -o |
Output file path |
--category / -c |
Run specific analyzers: security, naming, modules, best-practices |
--min-severity / -s |
Minimum severity: critical, high, medium, low, info |
--fail-on |
Exit code 1 if issues at this severity or above |
Rule Categories
Security (TF-SEC-001 to TF-SEC-020)
- S3 bucket encryption and public access
- Security group / NSG / Firewall open to 0.0.0.0/0
- RDS/database public access and encryption
- IAM wildcard policies
- KMS key rotation, EBS encryption
- Load balancer HTTPS enforcement
- Azure Key Vault purge protection
- Secrets in Terraform state (tls_private_key)
Naming Conventions (TF-NAM-001 to TF-NAM-008)
- Resource, variable, output, module snake_case enforcement
- Generic name detection (main, this, test)
Module Quality (TF-MOD-001 to TF-MOD-011)
- Module source version pinning
- Variable descriptions and type constraints
- Provider version management
- Backend configuration and state locking
Best Practices (TF-BP-001 to TF-BP-014)
- Resource tagging compliance
- Sensitive variable/output flags
- File organization and size
- .gitignore completeness
Example Output
╭─────────────── 🔍 tf-audit — Terraform Configuration Auditor ────────────────╮
│ 📂 Path: ./infrastructure │
│ 📄 Files: 5 Terraform files │
│ 📦 Resources: 16 resources scanned │
│ 🔌 Providers: aws, azurerm │
╰──────────────────────────────────────────────────────────────────────────────╯
Grade: F (0/100)
Issue Summary:
🔴 CRITICAL: 4
🟠 HIGH: 14
🟡 MEDIUM: 23
🔵 LOW: 10
⚪ INFO: 4
License
MIT
Metadata
Release files for tf-audit 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tf_audit-1.0.0.tar.gz | 29.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tf_audit-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.1 kB
Release files / tf_audit-1.0.0.tar.gz
| Download URL | tf_audit-1.0.0.tar.gz |
|---|---|
| Size | 29.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc90e465f08fe1d18d7acb66887eb6ca185cd431f68c60bff20bf7482b3636f1
|
|
BLAKE2b-256 checksum How to use checksums |
b96e94618c613eab12611cdccd1bc8ecc2fcc8b8c58db32a160801a28d39d0c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Release files / tf_audit-1.0.0-py3-none-any.whl
| Download URL | tf_audit-1.0.0-py3-none-any.whl |
|---|---|
| Size | 29.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e34b40d2a2f5ea5e3a4c8f12c3c0f972de5ba445bb3ba8b7e9407dd1cc919ad
|
|
BLAKE2b-256 checksum How to use checksums |
551c6af187aa0730f84fef3165ad36f98d4e8c18cc701bc3db9f02cc131c4f51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.7
|
Security for tf-audit 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.