/grc-engineer:scan-iacfrom grc-engineer
Scans Terraform, CloudFormation, Kubernetes, Azure ARM, and Pulumi IaC files for compliance violations against frameworks like SOC2, PCI-DSS, NIST. Supports detailed, summary, JSON, and SARIF output with optional auto-fix.
Ships in grc-engineer. Installing the plugin adds it to Claude Code.
Scans Infrastructure as Code (Terraform, CloudFormation, Kubernetes) for compliance violations and provides automated remediation suggestions.
/grc-engineer:scan-iac <directory> <frameworks> [options]
$1 - Directory to scan (e.g., ./terraform, ./k8s)$2 - Comma-separated frameworks (e.g., SOC2,PCI-DSS,NIST)$3 - Output format (optional): detailed, summary, json, sarif (default: detailed)$4 - Options (optional): --fix, --severity=high, --exclude=test/.tf files).yaml, .json templates).yaml manifests).json templates).yaml stack files)# Scan Terraform directory for multiple frameworks
/grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST detailed
# Quick summary scan
/grc-engineer:scan-iac ./infrastructure ISO,GDPR summary
# Scan with auto-fix
/grc-engineer:scan-iac ./terraform PCI-DSS detailed --fix
# High severity issues only
/grc-engineer:scan-iac ./k8s SOC2,NIST summary --severity=high
# Export SARIF for CI/CD integration
/grc-engineer:scan-iac ./terraform SOC2,PCI-DSS sarif
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IAC COMPLIANCE SCAN RESULTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Scan Target: ./terraform
Frameworks: SOC2, PCI-DSS, NIST 800-53
Files Scanned: 23 (15 .tf, 5 .yaml, 3 .json)
Scan Duration: 4.2s
SUMMARY:
✓ Satisfied: 42 controls (73%)
✗ Violations: 8 controls (14%)
⚠ Partial: 7 controls (12%)
ℹ Recommendations: 12
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
VIOLATIONS (8)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔴 HIGH SEVERITY (3)
[1] Encryption at Rest - Missing S3 Bucket Encryption
Frameworks: SOC2 CC6.7, PCI-DSS 3.4, NIST SC-28
File: terraform/s3_buckets.tf:12
Resource: aws_s3_bucket.data
Issue:
S3 bucket does not have server-side encryption enabled.
This violates encryption at rest requirements for all
three frameworks.
Current Configuration:
```hcl
resource "aws_s3_bucket" "data" {
bucket = "customer-data-bucket"
# Missing encryption configuration
}
```
✓ Remediation:
Add server-side encryption configuration:
```hcl
resource "aws_s3_bucket" "data" {
bucket = "customer-data-bucket"
# Required for SOC2 CC6.7, PCI 3.4, NIST SC-28
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256" # or "aws:kms" for PCI
}
}
}
}
```
Auto-fix available: Run with --fix flag
[2] Audit Logging - CloudTrail Retention Too Short
Frameworks: SOC2 CC7.3, PCI-DSS 10.7, NIST AU-11
File: terraform/cloudtrail.tf:8
Resource: aws_cloudtrail.audit
Issue:
CloudTrail log retention is set to 90 days, but PCI-DSS
requires 1 year minimum (365 days).
Current Configuration:
```hcl
resource "aws_cloudtrail" "audit" {
name = "audit-trail"
s3_bucket_name = aws_s3_bucket.logs.id
# Retention too short
event_selector {
...
}
}
resource "aws_s3_bucket_lifecycle_configuration" "logs" {
rule {
expiration {
days = 90 # ✗ TOO SHORT
}
}
}
```
✓ Remediation:
Update lifecycle rule to 365 days:
```hcl
resource "aws_s3_bucket_lifecycle_configuration" "logs" {
bucket = aws_s3_bucket.logs.id
rule {
id = "retention"
status = "Enabled"
# Keep online for 6 months
transition {
days = 180
storage_class = "GLACIER"
}
# Total retention: 1 year (PCI/SOC2 requirement)
expiration {
days = 365 # ✓ COMPLIANT
}
}
}
```
[3] Network Security - Security Group Too Permissive
Frameworks: PCI-DSS 1.2, NIST SC-7, SOC2 CC6.6
File: terraform/security_groups.tf:24
Resource: aws_security_group.web
Issue:
Security group allows unrestricted SSH access (0.0.0.0/0:22).
Violates least privilege and network segmentation requirements.
Current Configuration:
```hcl
resource "aws_security_group" "web" {
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # ✗ TOO PERMISSIVE
}
}
```
✓ Remediation:
Restrict SSH to specific IP ranges:
```hcl
resource "aws_security_group" "web" {
ingress {
description = "SSH from corporate VPN only"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.0/8"] # ✓ RESTRICTED
}
}
```
Or remove SSH entirely and use AWS Systems Manager Session Manager.
🟡 MEDIUM SEVERITY (5)
[4] Vulnerability Management - Missing Patch Management
Frameworks: NIST SI-2, PCI-DSS 6.2
File: terraform/ec2_instances.tf:45
Issue: No AWS Systems Manager Patch Manager configuration detected.
✓ Remediation:
Add patch baseline and maintenance window:
```hcl
resource "aws_ssm_patch_baseline" "compliance" {
name = "compliance-baseline"
operating_system = "AMAZON_LINUX_2"
approval_rule {
approve_after_days = 7
compliance_level = "CRITICAL"
patch_filter {
key = "CLASSIFICATION"
values = ["Security"]
}
}
}
resource "aws_ssm_maintenance_window" "patching" {
name = "critical-patching"
schedule = "cron(0 2 ? * SUN *)" # Weekly
duration = 3
cutoff = 1
}
```
[5] Access Control - Missing MFA for Root Account
Frameworks: NIST IA-2(1), PCI-DSS 8.3, SOC2 CC6.1
Issue: No evidence of MFA enforcement for root account.
✓ Remediation:
Enable MFA manually (cannot be automated via Terraform):
1. Log in to AWS Console as root
2. Navigate to IAM > Security Credentials
3. Activate MFA
Verify with:
```bash
aws iam get-account-summary | jq '.SummaryMap.AccountMFAEnabled'
```
... (3 more medium severity violations)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PARTIAL COMPLIANCE (7)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ [8] Encryption at Rest - KMS Rotation Not Enabled
Frameworks: NIST SC-12, PCI-DSS 3.6
File: terraform/kms.tf:5
Status: Partial
Current: KMS key exists but rotation disabled
Required: Annual key rotation enabled
✓ Fix:
```hcl
resource "aws_kms_key" "compliance" {
description = "Compliance encryption key"
enable_key_rotation = true # ✓ Add this
}
... (6 more partial compliance issues)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SATISFIED CONTROLS (42) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ SOC2 CC6.1 - IAM users configured with unique IDs ✓ PCI-DSS 8.1.1 - Unique user IDs enforced ✓ NIST AC-2 - Account management automated ✓ SOC2 CC7.2 - CloudWatch Logs enabled ✓ PCI-DSS 10.2 - Audit trails configured ✓ NIST SC-7 - VPC boundary protection in place ✓ SOC2 CC6.6 - Network segmentation implemented ... (35 more)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ RECOMMENDATIONS (12) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Consider enabling AWS Config for continuous compliance monitoring ℹ Add AWS GuardDuty for threat detection (SOC2 CC7.1) ℹ Implement AWS Security Hub for centralized findings ℹ Enable VPC Flow Logs for network monitoring (NIST AU-2) ℹ Add resource tagging for better compliance tracking ... (7 more)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COMPLIANCE SCORE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Overall: 73% ████████████████████░░░░░░
By Framework: SOC2: 78% ████████████████████░░░░ PCI-DSS: 65% ████████████████░░░░░░░░ NIST 800-53: 76% ███████████████████░░░░
Critical Issues: 3 (MUST FIX for compliance) High Priority: 5 (SHOULD FIX before audit) Medium Priority: 7 (GOOD TO FIX)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ NEXT STEPS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Fix critical issues (3):
Apply automated fixes: /grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST detailed --fix
Validate fixes: /grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST summary
Generate compliance report: /grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST json > report.json
Collect evidence after remediation: /grc-engineer:collect-evidence
### Summary Mode
IaC Compliance Scan: ./terraform Frameworks: SOC2, PCI-DSS, NIST 800-53
Compliance: 73% (42/57 controls)
Issues: 🔴 High: 3 (CRITICAL) 🟡 Medium: 5 ⚠ Partial: 7 ✓ Passing: 42
Top Issues:
Run with 'detailed' for full analysis.
### JSON Output (for CI/CD)
```json
{
"scan_timestamp": "2025-01-15T10:30:00Z",
"directory": "./terraform",
"frameworks": ["SOC2", "PCI-DSS", "NIST-800-53"],
"summary": {
"total_controls": 57,
"satisfied": 42,
"violations": 8,
"partial": 7,
"compliance_percentage": 73
},
"violations": [
{
"id": "V001",
"severity": "HIGH",
"control": "encryption_at_rest",
"frameworks": ["SOC2 CC6.7", "PCI-DSS 3.4", "NIST SC-28"],
"file": "terraform/s3_buckets.tf",
"line": 12,
"resource": "aws_s3_bucket.data",
"issue": "S3 bucket missing server-side encryption",
"remediation": {
"description": "Add server-side encryption configuration",
"code": "...",
"auto_fixable": true
}
}
],
"recommendations": [...],
"compliance_by_framework": {
"SOC2": 0.78,
"PCI-DSS": 0.65,
"NIST-800-53": 0.76
}
}
Outputs SARIF 2.1.0 format compatible with:
/grc-engineer:scan-iac ./terraform SOC2,PCI-DSS sarif > results.sarif
/grc-engineer:scan-iac ./terraform SOC2,PCI-DSS detailed --fix
Auto-fixes:
Backup: Creates .tf.backup files before modifications
name: IaC Compliance Scan
on: [pull_request]
jobs:
compliance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan Infrastructure
run: |
/grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST sarif > results.sarif
- name: Upload Results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
- name: Check Compliance Threshold
run: |
COMPLIANCE=$(jq '.summary.compliance_percentage' scan-results.json)
if [ "$COMPLIANCE" -lt 90 ]; then
echo "Compliance below 90%: $COMPLIANCE%"
exit 1
fi
compliance_scan:
stage: test
script:
- /grc-engineer:scan-iac ./terraform SOC2,PCI-DSS,NIST json > gl-sast-report.json
artifacts:
reports:
sast: gl-sast-report.json
/grc-engineer:generate-implementation - Generate compliant IaC/grc-engineer:map-controls-unified - Understand framework requirements/grc-engineer:find-conflicts - Identify conflicting requirements/grc-engineer:collect-evidence - Collect compliance evidenceWhat the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub devedge09/grckit --plugin grc-engineer18 commands in this plugin
3 plugins ship this exact command · first indexed Apr 26, 2026
Other plugins' commands for the same job