Terraform Security Scanner: 18 AWS Infrastructure Rules (SOC 2 CC6.1 & CIS AWS v5.0)
Static pre-merge checks for AWS Terraform (*.tf) resources with cross-file resource correlation
(S3 buckets ↔ Public Access Block / SSE / Versioning; VPC ↔ Flow Logs) — running 100% locally with zero AWS credentials.
Complete Terraform AWS Rule Catalog (TF001–TF018)
| Rule ID | Severity | Check Description | SOC 2 / CIS AWS v5.0 / ISO 27001 |
|---|---|---|---|
TF001 | CRITICAL | Hardcoded AWS access key (AKIA...) or plaintext password/secret in *.tf | SOC 2 CC6.1/CC6.7 · CIS 1.12 · ISO A.5.17/A.8.24 |
TF002 | CRITICAL | Security Group exposes SSH (22) or RDP (3389) to 0.0.0.0/0 or ::/0 | SOC 2 CC6.1/CC6.6 · CIS 5.2/5.3 · ISO A.8.20/A.8.21 |
TF003 | CRITICAL | Security Group exposes database/cache ports (5432, 3306, 6379, 27017, 9200) to internet | SOC 2 CC6.1/CC6.6 · CIS 5.2 · ISO A.8.20/A.8.22 |
TF004 | CRITICAL | Security Group allows all ports/protocols (-1 or 0..0) from 0.0.0.0/0 or ::/0 | SOC 2 CC6.1/CC6.6 · CIS 5.2 · ISO A.8.20 |
TF005 | CRITICAL | RDS aws_db_instance / aws_rds_cluster with publicly_accessible = true | SOC 2 CC6.1/CC6.6 · CIS 2.3.3 · ISO A.8.20/A.8.22 |
TF006 | CRITICAL | S3 public ACL (public-read / public-read-write) or missing full aws_s3_bucket_public_access_block | SOC 2 CC6.1/CC6.6 · CIS 2.1.4 · ISO A.5.15/A.8.20 |
TF007 | HIGH | RDS database missing encryption at rest (storage_encrypted != true) | SOC 2 CC6.1/CC6.7 · CIS 2.3.1 · ISO A.8.24 |
TF008 | HIGH | S3 bucket missing server-side encryption (aws_s3_bucket_server_side_encryption_configuration SSE-KMS/AES256) | SOC 2 CC6.1/CC6.7 · CIS 2.1.1 · ISO A.8.24 |
TF009 | HIGH | EC2 aws_instance / aws_launch_template allowing IMDSv1 (http_tokens != "required") | SOC 2 CC6.1/CC6.6 · CIS 5.6 · ISO A.5.17/A.8.9 |
TF010 | HIGH | EBS volume or EC2 root_block_device missing encrypted = true | SOC 2 CC6.1/CC6.7 · CIS 2.2.1 · ISO A.8.24 |
TF011 | HIGH | KMS key (aws_kms_key) missing automatic rotation (enable_key_rotation != true) | SOC 2 CC6.1/CC6.7 · CIS 3.6 · ISO A.8.24 |
TF012 | HIGH | CloudTrail disabled (enable_logging = false), single-region, or missing enable_log_file_validation | SOC 2 CC6.1/CC7.2 · CIS 3.1/3.2 · ISO A.8.15 |
TF013 | HIGH | Weak TLS protocol (< TLS 1.2) on ALB/NLB listener (ssl_policy) or CloudFront distribution | SOC 2 CC6.1/CC6.7 · CIS 2.1.1 · ISO A.8.24 |
TF014 | MEDIUM | RDS missing deletion_protection = true or backup_retention_period < 7 | SOC 2 CC6.1/A1.2 · CIS 2.3.1 · ISO A.8.13 |
TF015 | MEDIUM | aws_vpc missing aws_flow_log network audit logging | SOC 2 CC6.1/CC7.2 · CIS 3.7 · ISO A.8.15/A.8.20 |
TF016 | MEDIUM | aws_cloudwatch_log_group missing kms_key_id or retention_in_days | SOC 2 CC6.1/CC6.7/CC7.2 · CIS 3.4 · ISO A.8.15/A.8.24 |
TF017 | MEDIUM | aws_s3_bucket missing aws_s3_bucket_versioning (status = "Enabled") | SOC 2 CC6.1/A1.2 · CIS 2.1.3 · ISO A.8.13 |
TF018 | LOW | aws_lambda_function with plaintext secret-like env vars or missing kms_key_arn | SOC 2 CC6.1/CC6.7 · CIS 1.12 · ISO A.5.17/A.8.24 |
Example: CIS AWS v5.0 Hardened RDS & EC2 IMDSv2 Snippet (0 Findings)
resource "aws_db_instance" "prod" {
identifier = "prod-postgres"
engine = "postgres"
publicly_accessible = false
storage_encrypted = true
kms_key_id = aws_kms_key.prod.arn
deletion_protection = true
backup_retention_period = 14
}
resource "aws_instance" "worker" {
ami = "ami-0123456789abcdef0"
instance_type = "t3.medium"
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
}
root_block_device {
encrypted = true
kms_key_id = aws_kms_key.prod.arn
}
}