Configures tfsec for Terraform-specific security scanning - covers AWS / Azure / GCP / Kubernetes / OpenStack / Oracle / DigitalOcean / CloudStack, custom YAML rules, and SARIF / JUnit / Markdown output. Note: tfsec is transitioning to Trivy per Aqua Security, so new projects evaluate that first. Use for an existing Terraform-only tfsec stack; for the consolidated forward-path scanner use trivy-config, for the broadest multi-framework checks use checkov-policy, and for wider platform breadth use kics-policy.
75
94%
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