Use for any question or task about scanning infrastructure code for misconfigurations with one tool, including Kubernetes manifests, Terraform, CloudFormation, Helm, ARM and Dockerfiles that run as root, or migrating off tfsec: trivy config with severity gating, .trivyignore suppressions, custom Rego checks and SARIF for GitHub code scanning. Legacy tfsec is in its references.
89%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Companion reference for trivy-config. tfsec is transitioning to Trivy per
Aqua Security's own guidance - the host skill is the forward path, and
tfsec's checks ship inside trivy config. Keep this reference for an
existing Terraform-only tfsec stack while the migration lands.
Per tfsec-home, tfsec is transitioning to Trivy, Aqua Security's consolidated scanner. For new projects, evaluate Trivy first; tfsec remains stable for existing usage.
tfsec . against the Terraform tree, starting at
--minimum-severity HIGH to keep the signal high (Step 2).tfsec:ignore: comments (Step 4).tfsec . --minimum-severity HIGH after
remediation and assert it reports no HIGH findings before
merging; if any remain, fix or justify-ignore them and re-run.# macOS
brew install tfsec
# Linux
curl -L https://github.com/aquasecurity/tfsec/releases/latest/download/tfsec-linux-amd64 \
-o /usr/local/bin/tfsec
chmod +x /usr/local/bin/tfsec# Scan current directory
tfsec .
# Scan specific path
tfsec ./terraform/
# Concise output
tfsec . --concise-output
# Specific severity threshold
tfsec . --minimum-severity HIGHPer tfsec-home: "JSON and SARIF output capabilities for integration with external tools and workflows."
# JSON
tfsec . -f json > tfsec.json
# SARIF (GitHub Code Scanning)
tfsec . -f sarif -O tfsec.sarif
# JUnit XML
tfsec . -f junit -O tfsec.xml
# Markdown (PR comments)
tfsec . -f markdown# Skip specific checks
tfsec . -e aws-s3-enable-bucket-encryption,aws-s3-enable-versioning
# Skip everything matching a pattern
tfsec . -e aws-s3-*Inline:
# main.tf
resource "aws_s3_bucket" "public_data" {
# tfsec:ignore:aws-s3-enable-bucket-encryption Public dataset, not encrypted by design
# tfsec:ignore:aws-s3-enable-bucket-logging Public CDN, no audit logging needed
bucket = "my-public-data"
acl = "public-read"
}Author custom YAML rules for team-specific policy the built-in set misses: tfsec-custom-rules-and-ci.md.
Run the official tfsec action with SARIF upload to GitHub Code Scanning: tfsec-custom-rules-and-ci.md.
Per tfsec-home, tfsec covers AWS (S3, EC2, RDS, IAM, Lambda, API Gateway, and 30+ services), Azure (App Service, Storage, Database, Container, Key Vault), Google Cloud (Compute, GKE, SQL, Storage, IAM, BigQuery), plus Kubernetes, OpenStack, Oracle, DigitalOcean, and CloudStack.
For unsupported clouds, fall back to OPA / Conftest with custom
Rego per policy-as-code-runner.
Per tfsec-home guidance:
# Install Trivy
brew install trivy # or apt-get / etc.
# Trivy includes tfsec's checks under `trivy config`
trivy config ./terraform/The migration is mostly mechanical - Trivy ingests the same .tf files; rule names may differ.
Multiple scanners catch overlapping but non-identical issues.
tfsec is faster and Terraform-specific; Checkov (checkov-policy) is
broader; the KICS tool adds different rule classes.
tfsec . -f json > tfsec.json
checkov -d . -o json > checkov.json
kics scan -p . --report-formats json
# unify results across the three scannersA team runs tfsec on an AWS Terraform module while planning a Trivy migration.
brew install tfsec, then tfsec ./terraform/ --minimum-severity HIGH to focus on the worst findings first.aws-s3-enable-bucket-encryption) as HIGH.# tfsec:ignore:aws-s3-enable-bucket-encryption Public dataset, not encrypted by design inline.aquasecurity/tfsec-action@v1.0.3 with format: sarif;
the SARIF upload posts remaining findings to the Security tab.trivy config ./terraform/ and
confirm the same .tf files scan under Trivy.Result: HIGH-severity misconfigurations gate the build, intentional exceptions are documented inline, and the Trivy forward-path is validated before switching.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Starting new tfsec adoption in 2026+ without Trivy evaluation | Investing in deprecating path. | Evaluate Trivy first (Step 8). |
tfsec:ignore without justification comment | Skips invisible to reviewers; security debt. | Always include reason (Step 4 example). |
--minimum-severity LOW everywhere | Noise floods CI; team disables. | Start HIGH; ratchet down. |
| Custom rules without tests | Bugs in custom rules let bad config through. | Cross-reference with OPA-tested policies (Step 5 + Conftest). |
| Single-scanner approach | Tool-specific gaps. | Multiple scanners (Step 9). |
checkov-policy - sister scanner.policy-as-code-runner -
custom OPA / Rego policies (for unsupported clouds or custom
rules).