Runs Trivy's misconfiguration scanner (`trivy config`) against IaC directories to detect security issues across Terraform, CloudFormation, Kubernetes manifests, Helm charts, Dockerfiles, and Azure ARM templates - installs Trivy, scans with severity gating via `--exit-code`, suppresses findings via `.trivyignore` / `.trivyignore.yaml` or inline annotations, extends built-in checks with custom Rego policies, and emits SARIF for GitHub Code Scanning. Trivy is the tfsec successor - the forward path from tfsec per Aqua Security's own migration guidance - and the legacy tfsec workflow (install, custom YAML rules, ignore annotations, migration steps) is kept in references/tfsec-legacy.md. Use when adopting a consolidated IaC scanner for new projects, migrating away from tfsec (or still operating a Terraform-only tfsec stack), or scanning mixed IaC stacks with a single tool.
74
93%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Medium
Suggest reviewing before use
# .tfsec/custom_checks.yml
checks:
- code: CUS001
description: Ensure all EC2 instances have a cost_center tag
impact: Untagged resources cannot be allocated to cost centers
resolution: Add a cost_center tag
requiredTypes:
- resource
requiredLabels:
- aws_instance
severity: HIGH
matchSpec:
name: tags
action: contains
value: cost_center
errorMessage: EC2 instance is missing cost_center tagjobs:
tfsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: aquasecurity/tfsec-action@v1.0.3
with:
additional_args: --minimum-severity HIGH
format: sarif
output_file_path: tfsec.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: tfsec.sarif