tfsec — Static Security Scanner for Terraform Code
Catch security misconfigurations in Terraform before they reach production. tfsec scans HCL files for hundreds of cloud security rules across AWS, Azure, and GCP with zero configuration.
What it is
tfsec is a static analysis security scanner for Terraform HCL files. It checks for hundreds of built-in security rules covering AWS, Azure, and GCP resources. It runs with zero configuration and flags issues like unencrypted storage, overly permissive IAM policies, and missing logging before you deploy.
It targets Terraform users and DevOps teams who want fast, automated security checks integrated into their development workflow and CI pipelines.
How it saves time or tokens
tfsec runs in seconds against your Terraform codebase and provides clear, actionable output. Each finding includes the rule ID, severity, affected resource, and a link to documentation explaining the fix. No cloud credentials or deployed infrastructure needed.
How to use
- Install tfsec:
brew install tfsec
# Or via Go:
go install github.com/aquasecurity/tfsec/cmd/tfsec@latest
- Scan your Terraform directory:
tfsec ./terraform
- Review findings and fix flagged resources.
Example
# Install
brew install tfsec
# Scan current directory
tfsec .
# Scan specific directory with severity filter
tfsec ./infra --minimum-severity HIGH
# Output as JSON for CI
tfsec ./infra -f json
# Exclude specific rules
tfsec . --exclude aws-s3-enable-versioning
Related on TokRepo
- AI Tools for Security — Security scanning and compliance tools
- AI Tools for DevOps — Infrastructure automation and DevOps tools
Key considerations
When evaluating tfsec for your workflow, consider the following factors. First, assess whether your team has the technical prerequisites to adopt this tool effectively. Second, evaluate the maintenance burden against the productivity gains. Third, check community activity and documentation quality to ensure long-term viability. Integration with your existing toolchain matters more than feature count alone. Start with a small pilot project before rolling out across the organization. Monitor resource usage during the initial adoption phase to identify bottlenecks early. Document your configuration decisions so team members can onboard independently.
Common pitfalls
- tfsec has been absorbed into Trivy by Aqua Security; new users should consider using Trivy's Terraform scanning instead.
- Variable values from tfvars files are not always resolved; some findings may be false positives for dynamically set values.
- Custom modules with complex variable passing may not be fully analyzed; run tfsec at the module level for better coverage.
Frequently Asked Questions
tfsec's functionality has been integrated into Trivy by Aqua Security. The standalone tfsec tool still works but new development focuses on Trivy. For new projects, consider using Trivy for Terraform scanning.
tfsec is Terraform-specific with a focus on speed and simplicity. Checkov covers multiple IaC formats (Terraform, CloudFormation, Kubernetes). tfsec may find Terraform-specific issues that Checkov misses and vice versa.
Yes. tfsec provides an official GitHub Action. Add it to your workflow YAML and it scans on every pull request, posting results as PR comments or failing the check if issues are found.
Add 'tfsec:ignore:RULE_ID' as a comment above the flagged resource in your Terraform file. This suppresses the specific finding while keeping other checks active.
Yes. tfsec supports custom rules defined in JSON or YAML. Place them in a .tfsec directory and they are picked up automatically during scans.
Citations (3)
- tfsec GitHub— Static security scanner for Terraform HCL files
- tfsec Documentation— Hundreds of security rules for AWS, Azure, and GCP
- Trivy GitHub— Absorbed into Trivy by Aqua Security
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.