Checkov

Reference for Checkov security scanning in the AWS Terraform Starter Kit.


Overview

Checkov is an open-source static analysis tool from Bridgecrew/Palo Alto Networks. It scans Terraform configurations for misconfigurations that could lead to security, compliance, or operational issues.

Integration

CommandDescription
make security-scanRun Checkov across all environments
make validate-fullRun Checkov as part of full validation

Running manually

# Using make
make security-scan

# Or directly
cd environments/staging/
checkov --directory . --framework terraform

Target a single file:

checkov --file main.tf --framework terraform

Security issues detected

CategoryChecks
S3 SecurityUnencrypted buckets, public access, missing versioning
IAM PoliciesOverly permissive policies, wildcard actions, missing MFA
Network SecurityOpen security groups, unencrypted traffic, missing VPC flow logs
EncryptionMissing encryption at rest and in transit
LoggingMissing CloudTrail, CloudWatch logs, access logging
CompliancePCI-DSS, HIPAA, CIS AWS Foundations, SOC2

Example output:

Check: CKV_AWS_18: "Ensure S3 bucket has server-side encryption enabled"
  FAILED for resource: aws_s3_bucket.data
  File: /environments/staging/main.tf:15-18
  Guide: https://docs.bridgecrew.io/docs/s3_14-data-encrypted-at-rest

Suppressing false positives

Use inline comments with justification:

resource "aws_s3_bucket" "logs" {
  #checkov:skip=CKV_AWS_18:Encryption not required for access logs
  bucket = "app-access-logs"
}

Always include a justification explaining why the check doesn't apply.

Configuration

The starter kit includes .checkov.yml:

---
# Checkov configuration file

# Framework to scan
framework: terraform

# Skip specific checks (add check IDs as needed)
skip-check:
  # Example: Skip S3 bucket logging checks for demo buckets
  # - CKV_AWS_18  # S3 Bucket should have access logging enabled
  # - CKV_AWS_21  # S3 Bucket should have versioning enabled

# Exclude specific directories
skip-path:
  - .terraform/
  - .git/
  - tests/

# Enable downloading external modules
download-external-modules: true

Output formats

FormatCommandUse case
Compact--compactCI/CD pipelines
JSON--output jsonCustom tooling
JUnit XML--output junitxmlTest reporting

Severity filtering

Focus on high-severity issues:

checkov --directory . --framework terraform --check CRITICAL,HIGH

Best practices

  • Run locally first: Use make security-scan before committing
  • Review all failures: Understand what checks protect against
  • Document suppressions: Always add clear justifications
  • Update regularly: Keep Checkov up to date for new checks
  • Combine with TFLint: Security (Checkov) + code quality (TFLint)

Next steps