Terraform HCL Security Reference · TF001–TF018

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.

Open Free 0-Upload Terraform Scanner Get Solo CLI ($49 One-Time) Get Team SOC 2 Pack ($99)

Complete Terraform AWS Rule Catalog (TF001–TF018)

Rule ID Severity Check Description SOC 2 / CIS AWS v5.0 / ISO 27001
TF001CRITICALHardcoded AWS access key (AKIA...) or plaintext password/secret in *.tfSOC 2 CC6.1/CC6.7 · CIS 1.12 · ISO A.5.17/A.8.24
TF002CRITICALSecurity Group exposes SSH (22) or RDP (3389) to 0.0.0.0/0 or ::/0SOC 2 CC6.1/CC6.6 · CIS 5.2/5.3 · ISO A.8.20/A.8.21
TF003CRITICALSecurity Group exposes database/cache ports (5432, 3306, 6379, 27017, 9200) to internetSOC 2 CC6.1/CC6.6 · CIS 5.2 · ISO A.8.20/A.8.22
TF004CRITICALSecurity Group allows all ports/protocols (-1 or 0..0) from 0.0.0.0/0 or ::/0SOC 2 CC6.1/CC6.6 · CIS 5.2 · ISO A.8.20
TF005CRITICALRDS aws_db_instance / aws_rds_cluster with publicly_accessible = trueSOC 2 CC6.1/CC6.6 · CIS 2.3.3 · ISO A.8.20/A.8.22
TF006CRITICALS3 public ACL (public-read / public-read-write) or missing full aws_s3_bucket_public_access_blockSOC 2 CC6.1/CC6.6 · CIS 2.1.4 · ISO A.5.15/A.8.20
TF007HIGHRDS database missing encryption at rest (storage_encrypted != true)SOC 2 CC6.1/CC6.7 · CIS 2.3.1 · ISO A.8.24
TF008HIGHS3 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
TF009HIGHEC2 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
TF010HIGHEBS volume or EC2 root_block_device missing encrypted = trueSOC 2 CC6.1/CC6.7 · CIS 2.2.1 · ISO A.8.24
TF011HIGHKMS key (aws_kms_key) missing automatic rotation (enable_key_rotation != true)SOC 2 CC6.1/CC6.7 · CIS 3.6 · ISO A.8.24
TF012HIGHCloudTrail disabled (enable_logging = false), single-region, or missing enable_log_file_validationSOC 2 CC6.1/CC7.2 · CIS 3.1/3.2 · ISO A.8.15
TF013HIGHWeak TLS protocol (< TLS 1.2) on ALB/NLB listener (ssl_policy) or CloudFront distributionSOC 2 CC6.1/CC6.7 · CIS 2.1.1 · ISO A.8.24
TF014MEDIUMRDS missing deletion_protection = true or backup_retention_period < 7SOC 2 CC6.1/A1.2 · CIS 2.3.1 · ISO A.8.13
TF015MEDIUMaws_vpc missing aws_flow_log network audit loggingSOC 2 CC6.1/CC7.2 · CIS 3.7 · ISO A.8.15/A.8.20
TF016MEDIUMaws_cloudwatch_log_group missing kms_key_id or retention_in_daysSOC 2 CC6.1/CC6.7/CC7.2 · CIS 3.4 · ISO A.8.15/A.8.24
TF017MEDIUMaws_s3_bucket missing aws_s3_bucket_versioning (status = "Enabled")SOC 2 CC6.1/A1.2 · CIS 2.1.3 · ISO A.8.13
TF018LOWaws_lambda_function with plaintext secret-like env vars or missing kms_key_arnSOC 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
  }
}