Skip to content

tfsec vs Trivy

Suphi Cankurt

Written by Suphi Cankurt

tfsec vs Trivy
Key Takeaways
  • Aqua encourages tfsec users to move to Trivy and says engineering attention is directed at Trivy, while tfsec remains available for the time being.
  • The basic command changes from tfsec <dir> to trivy config <dir>, but that does not prove identical IDs, suppressions, reports, or custom-policy behavior.
  • Aqua says tfsec laid the foundations for Trivy’s Terraform and misconfiguration scanning and describes Trivy as using the same Terraform scanning engine.
  • Trivy’s current IaC coverage includes Terraform source and plan data, CloudFormation, ARM, Kubernetes, Helm, Dockerfiles, and arbitrary JSON or YAML.
  • Capture a pinned tfsec baseline and compare Trivy results before changing a blocking CI gate or deleting tfsec configuration.

What happened to tfsec?#

Aqua encourages tfsec users to move to Trivy. The tfsec README says the project will remain available for the time being, but engineering attention is directed at Trivy.

The first command change is simple: replace tfsec <dir> with trivy config <dir>. The full migration is not necessarily a one-line swap because flags, check IDs, custom policies, suppressions, output schemas, and failure behavior may differ.

Aqua says tfsec laid the foundations for Trivy’s IaC scanning and that Trivy uses the same Terraform scanning engine. Treat that as a migration path, not proof of identical results or interfaces.

What are the key differences?#

AreatfsecTrivy
Project directionRemains available for the time being; Aqua directs engineering attention to TrivyAqua’s recommended transition target
Open-source licenseMITApache License 2.0
Primary commandtfsec <dir>trivy config <dir> for configuration scanning
Configuration scopeStatic analysis of Terraform codeTerraform source and plans, CloudFormation, ARM, Kubernetes, Helm, Dockerfiles, JSON, and YAML
Other targetsNot part of tfsec’s documented purposeImages, filesystems, repositories, rootfs, VM images, Kubernetes clusters, and SBOMs
Custom checkstfsec custom checks and user-defined Rego behaviorRego custom misconfiguration checks with Trivy metadata and input contracts
ReportsHuman-readable, JSON, CSV, Checkstyle, SARIF, JUnit, and other tfsec formatsTable, JSON, SARIF, templates, SBOM, and GitHub dependency snapshot
Variable flag example--tf-vars-file--tf-vars in Aqua’s migration guide
Migration riskExisting gate and downstream contractMust be compared before replacing the existing gate

The table follows current project documentation. Pin the exact releases you test because defaults and interfaces can change.

tfsec-to-Trivy migration details#

What Aqua officially says#

Aqua’s tfsec README says scanning work is being consolidated in Trivy. It describes tfsec as a foundation for Trivy’s IaC and Terraform scanning and encourages the community to transition.

The same statement says tfsec remains available for the time being. It does not say the repository has been deleted, that every form of maintenance stopped, or that every tfsec feature already behaves identically in Trivy.

That wording matters. “Engineering attention moved to Trivy” is supported; “tfsec gets no new checks” or “Trivy contains every tfsec rule unchanged” requires stronger release and catalog evidence.

What changes at the command line#

Aqua’s migration guide begins with this command change:

# Existing tfsec scan
tfsec <dir>

# Trivy configuration scan
trivy config <dir>

It also documents a different variable flag:

# tfsec
tfsec <dir> --tf-vars-file <vars.tf>

# Trivy
trivy config --tf-vars <vars.tf> <dir>

The guide shows separate report commands and notes that Trivy supplies table, JSON, SARIF, template, and SBOM output paths. Current Trivy documentation also supports converting saved JSON into other formats.

What does not follow from a shared engine#

A shared Terraform scanning foundation does not guarantee identical policy bundles or result contracts. Trivy retrieves built-in checks as a bundle, while tfsec has its own release and configuration history.

Check IDs can be renamed, replaced, split, or removed. Suppression syntax and scope may differ, even when two findings describe the same Terraform problem.

Custom Rego also needs testing. Trivy defines its own package, metadata, namespace, selector, input, and result conventions, so a policy that parses in tfsec is not automatically a valid Trivy policy.

JSON and SARIF consumers are another boundary. A dashboard, allowlist, or CI annotation may depend on field names and fingerprints rather than the visible finding message.

Trivy’s broader configuration scope#

Trivy’s current IaC coverage lists Terraform source, Terraform plan JSON or snapshots, CloudFormation, Azure ARM, Kubernetes, Helm, Dockerfiles, and arbitrary JSON or YAML.

This scope is broader than tfsec’s documented purpose as a Terraform static analyzer. It does not mean every Trivy parser uses the same check catalog or that putting several file types in one directory guarantees complete coverage.

Trivy also exposes targets for container images, filesystems, repositories, root filesystems, virtual machine images, Kubernetes clusters, and SBOMs. Those targets use different scanner combinations and may require separate credentials or databases.

Keep the migration focused. Replacing tfsec’s Terraform gate and adding image, repository, or cluster scanning are separate control changes and should be tested separately.

Reports and CI failure behavior#

tfsec returns a non-zero status when it finds problems unless configured otherwise. Its README documents human-readable, JSON, CSV, Checkstyle, SARIF, and JUnit output among its formats.

Trivy uses --exit-code to set the return code when matching issues are found. Severity and scanner filters affect what enters the report and can therefore affect the gate you build around it.

Test at least four cases: a clean Terraform fixture, a known policy failure, a parse error, and a scanner or checks-bundle failure. Keep those outcomes distinct in CI.

A zero-finding report is not enough if the wrong path was scanned or Terraform failed to parse. Preserve raw output during the migration window so differences can be investigated.

What should you do now?#

If tfsec is already blocking CI#

  1. Pin the current tfsec version and repository revision.
  2. Save its command, configuration, raw output, exit code, suppressions, and custom checks.
  3. Run a pinned Trivy version with trivy config on the same inputs.
  4. Compare findings, missing findings, new findings, parse errors, paths, IDs, severities, and exit codes.
  5. Translate variable and report flags using Aqua’s migration guide.
  6. Test each suppression and custom policy rather than copying it blindly.
  7. Update JSON, SARIF, dashboard, and allowlist consumers.
  8. Remove tfsec only after the Trivy gate reproduces the controls you need.

If you are starting a new project#

Evaluate Trivy first because Aqua directs engineering attention there. Build a small Terraform fixture set with one compliant and one failing example for each important policy.

If Trivy misses a requirement, write and test a custom Rego check or compare another maintained scanner. Checkov vs Trivy covers the IaC policy and target differences, while Checkov vs KICS compares two other policy models.

If migration exposes a gap#

Do not remove the existing control just to complete the tool migration. Keep a pinned tfsec job temporarily if it is the only tested implementation of a required check.

Record the gap with a failing fixture. Then replace it with a verified Trivy policy or another scanner and retire tfsec after the new control passes the same fixture.

Both projects appear in the IaC security tools category.

How this comparison was verified#

Official sources#

Frequently Asked Questions

Is tfsec still maintained?
Aqua’s tfsec README says tfsec will remain available for the time being, while engineering attention is directed at Trivy. That supports planning a migration, but it is more precise than calling tfsec removed or claiming no further maintenance of any kind.
What replaced tfsec?
Aqua encourages tfsec users to transition to Trivy and says tfsec laid the foundations for Trivy’s IaC and Terraform scanning. The primary migration command is trivy config <dir>, but interfaces and outputs still need validation before treating Trivy as a drop-in replacement.
How do I migrate from tfsec to Trivy?
Start by capturing a pinned tfsec baseline, then run trivy config <dir> on the same revision. Translate variable and report flags with Aqua’s migration guide, compare findings and parse errors, test suppressions and custom policies, update report consumers, and only then remove tfsec from CI.
Do tfsec checks and custom policies work unchanged in Trivy?
Do not assume so. Aqua describes a shared Terraform scanning foundation, but the migration guide documents command and flag differences and asks users to report unavailable tfsec features. Verify every blocking check, suppression, custom policy, ID, and downstream report field you rely on.
Should I choose tfsec for a new project?
Start by evaluating Trivy because Aqua directs engineering attention there and recommends the transition. If Trivy does not reproduce a required tfsec behavior, document the gap and keep the pinned tfsec control temporarily while you test an alternative or replacement policy.
Suphi Cankurt

Written & maintained by

Suphi Cankurt

Eight years on the vendor side of application-security sales — thousands of evaluations and demos. I started AppSec Santa in 2022 to put that insider view to work for buyers. Independent of any vendor, paid by none, and honest about what fits whom.