Skip to main content

SOC2 Compliance Terraform Registry PyPI version PyPI downloads Docker Terraform LocalStack Python License

CloudCompliance - SOC2-Ready AWS IaC

Infrastructure as Code that provisions a SOC2-aligned AWS security baseline with 10 controls and 46 resources - deployable in one command. Includes drift detection, AI compliance assistant, score history, auto-remediation and a live dashboard.

The Problem

Startups spend 6–12 months retrofitting SOC2 controls onto infrastructure that was never designed to be compliant. Security is an afterthought — CloudTrail gets enabled after an incident, encryption gets added before an audit, RBAC gets tightened only when required.

This IaC eliminates that retrofit entirely. Every SOC2 control is provisioned automatically at infrastructure creation time.

Scope note: This IaC implements the technical infrastructure controls mapped to SOC2 Common Criteria CC6–CC8 and Availability A1. Full SOC2 Type II certification additionally requires organizational policies, vendor management, employee training, and 6–12 months of evidence collection.


Quick Start

Requirements: Python 3.9+, Terraform, Docker

# 1. Install CLI
pip install cloudcompliance

# 2. Clone the repo
git clone https://github.com/KADHIRAVANEG/cloudcompliance.git
cd terraform-aws-cloudcompliance
cp .env.example .env  # add your API keys

# 3. Start everything in one command
bash scripts/start.sh

# Or step by step:
docker run --rm -d -p 4566:4566 localstack/localstack:3.4.0
make deploy
cloudcompliance report
cloudcompliance drift
cloudcompliance serve   # → http://localhost:8080

What's New in v2.3 (Observability & Multi-Cloud Upgrade)

  • 📊 Prometheus & OpenTelemetry /metrics Exporter: Emits real-time compliance scores, controls health, drift counts, and remediation stats in standard Prometheus exposition format (cloudcompliance serve & cloudcompliance metrics). Includes ready-to-import Grafana Dashboard JSON (dashboards/grafana_compliance_dashboard.json).
  • 🌍 True Multi-Cloud Starter IaC (cloudcompliance init): Generates production-ready, compliance-first Terraform configurations for AWS, Azure (Key Vault, Storage Account TLS 1.2, NSGs, Log Analytics), and GCP (Cloud KMS KeyRing, GCS bucket versioning, custom VPC, Cloud Audit logs).
  • 🤖 Multi-LLM AI Assistant (cloudcompliance ask): Flexible, privacy-first assistant supporting OpenAI (gpt-4o), Anthropic Claude (claude-3-5-sonnet), AWS Bedrock, local air-gapped Ollama, NVIDIA NIM, and deterministic offline regulatory guidance.
  • 🔍 Deep Instance-Level Resource Attribute Evaluator: Inspects actual security configurations on individual resources (open SSH/RDP/database security groups, unencrypted RDS storage, unencrypted EBS volumes, publicly accessible databases, and disabled KMS key rotation).

Features Introduced in v2.2

  • 🛡 GitHub Code Scanning & SARIF Export (--sarif / --format sarif): Generates OASIS SARIF v2.1.0 output for compliance violations and drift findings for native integration into GitHub's Security > Code Scanning Alerts dashboard (github/codeql-action/upload-sarif).
  • ⚡ Interactive Starter Wizard (cloudcompliance init): Interactive terminal wizard that scaffolds compliant main.tf, variables.tf, terraform.tfvars, and .env.example pre-configured for your provider, framework, and environment.
  • 🌐 Multi-Region CSPM Scanning (scan --live --all-regions / --regions): Inspects all active AWS regions concurrently via AWS APIs, uncovering unencrypted resources or unmonitored subnets in secondary regions.
  • 🔔 Multi-Channel Alerting (Teams, Discord, Slack, Generic Webhooks): Dispatches real-time compliance score regressions and drift events across Slack, Microsoft Teams, Discord embeds, and PagerDuty/Datadog-compatible generic webhooks.
  • Signed Executive Auditor PDF Reports (--pdf): Generates formal, audit-ready PDF reports with SOC2/HIPAA/PCI-DSS score badges, SHA-256 cryptographic evidence fingerprints, and auditor sign-off blocks.
  • GitHub PR Compliance Bot & Action: Turn compliance into an automated PR guard. Compares base vs. PR compliance scores, blocks regressions, and posts interactive visual Markdown comments directly to PRs.
  • Live Agentless AWS Scanner (CSPM scan --live): Connects directly to AWS APIs via boto3 to audit real-world infrastructure posture without requiring a terraform.tfstate file.
  • Interactive Web Dashboard (cloudcompliance serve): Trigger on-demand drift scans directly in the browser, download complete auditor .zip bundles with SHA-256 manifests, and switch frameworks in real time.

## CLI Commands

# Interactive Starter Wizard (Bootstraps tailored, compliant IaC)
cloudcompliance init
cloudcompliance init --provider aws --framework soc2 --env prod --non-interactive
cloudcompliance init --provider azure --framework hipaa --env prod --non-interactive
cloudcompliance init --provider gcp --framework pcidss --env prod --non-interactive

# Deploy baseline infrastructure
make deploy

# Generate compliance evidence report (Default: SOC2)
cloudcompliance report
cloudcompliance report --framework hipaa
cloudcompliance report --framework pcidss

# Export Prometheus metrics
cloudcompliance metrics

# Ask Multi-LLM Assistant
cloudcompliance ask "What do I need to achieve 100% SOC2 compliance?"
cloudcompliance ask "Is our infrastructure compliant?" --provider ollama
cloudcompliance ask "How do I fix drift findings?" --provider openai --model gpt-4o

# Generate signed Executive Auditor PDF report
cloudcompliance report --pdf

# Generate OASIS SARIF v2.1.0 for GitHub Code Scanning
cloudcompliance report --sarif
cloudcompliance report --format sarif

# Live Agentless AWS Scanner (CSPM mode — no tfstate required)
cloudcompliance scan --live
cloudcompliance scan --live --framework hipaa --pdf

# Multi-Region CSPM Scanning across all active regions
cloudcompliance scan --live --all-regions --sarif
cloudcompliance scan --live --regions us-east-1,eu-west-1,ap-southeast-1

# GitHub PR Compliance Guard & Commenter
cloudcompliance pr-check --min-score 80 --fail-on-regression
cloudcompliance pr-check --current-state pr.tfstate --base-state base.tfstate --post-comment

# Use remote state (S3) or custom OPA policies
cloudcompliance report --tfstate s3://my-bucket/terraform.tfstate --rego custom-policy.rego

# Detect infrastructure drift
cloudcompliance drift
cloudcompliance drift --tfstate s3://my-bucket/terraform.tfstate

# Auto-remediate drift findings (Auto-generates Terraform imports)
cloudcompliance remediate
cloudcompliance remediate --dry-run

# View compliance score history
cloudcompliance history
cloudcompliance history --export

# Ask AI about your compliance state
cloudcompliance ask "am I ready for a SOC2 audit?"

# Open live interactive compliance dashboard
cloudcompliance serve

# Scheduled drift detection (runs every hour)
cloudcompliance schedule

GitHub Actions PR Compliance Gate

Drop CloudCompliance straight into your GitHub CI/CD pipeline using the reusable GitHub Action:

name: "Compliance PR Guard"
on: [pull_request]

jobs:
  compliance-gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: JOKER-53/terraform-aws-cloudcompliance@v2
        with:
          tfstate-path: 'terraform/terraform.tfstate'
          framework: 'soc2'
          min-score: '80'
          fail-on-regression: 'true'
          post-comment: 'true'
          github-token: ${{ secrets.GITHUB_TOKEN }}

GitHub Code Scanning & SARIF Integration

Export OASIS SARIF v2.1.0 compliance and drift results directly into GitHub's native Security Code Scanning dashboard:

name: "Compliance Security Scan"
on: [push, pull_request]

jobs:
  sarif-compliance:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: Install CloudCompliance
        run: pip install cloudcompliance
      - name: Generate SARIF Compliance Report
        run: cloudcompliance report --framework soc2 --sarif
      - name: Upload SARIF to GitHub Code Scanning
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: compliance/soc2_compliance_report.sarif

Live Interactive Dashboard

CloudCompliance Live Dashboard

cloudcompliance serve

Opens an interactive dashboard at http://localhost:8080 featuring:

  • Framework Switcher: Seamlessly toggle between SOC 2 Type II, HIPAA, and PCI-DSS views.
  • On-Demand Drift Scanning: Click "Run Drift Scan" to trigger real-time AWS drift analysis.
  • Download Audit Bundle: Download complete .zip package with JSON evidence, Markdown reports, executive PDF, and cryptographic SHA-256 manifest.
  • Real-time Compliance Score Ring: Visual compliance gauge with breakdown by control.
  • Auto-Remediation Log: Live tracking of automated fixes and PRs.

SOC2 Control Coverage

SOC2 Compliance Report

Control Title Resources Enforced
CC6.1 Network Isolation VPC, private subnets, deny-all security group
CC6.2 Authentication Controls IAM password policy, MFA alert, least-privilege role
CC6.3 Access Revocation IAM role policies, access analyzer alarms
CC6.6 Transmission Protection HTTPS-only S3 bucket policy, TLS enforcement
CC6.7 Encryption at Rest KMS CMK, S3 server-side encryption
CC7.1 Threat Detection CloudWatch alarms, AWS Config recorder + rules
CC7.2 Audit Logging Versioned audit bucket, VPC flow logs, Config delivery
CC7.3 Incident Response Log metric filters, unauthorized API call detection
CC8.1 Change Management IaC-controlled infra, Config recorder status
A1.1 Availability S3 versioning, retention policies, backup role

10 controls · 46 AWS resources · 100% compliance score


What Gets Provisioned (46 resources across 9 modules)

Networking — CC6.1

  • Private VPC (10.0.0.0/16) with 2 private subnets
  • No public subnets — zero internet exposure by default
  • Default-deny security group
  • VPC Flow Logs → CloudWatch (90-day retention)

Logging — CC7.2

  • Dedicated audit S3 bucket with versioning
  • Delete protection + HTTPS-only policy
  • AWS Config delivery channel

Encryption — CC6.7

  • KMS Customer Managed Key with automatic rotation
  • S3 encrypted data bucket with KMS SSE
  • HTTPS-only bucket policy

IAM — CC6.2 + CC6.3

  • Password policy: 14 chars, complexity, 90-day rotation
  • Least-privilege IAM role — S3 read + KMS decrypt only
  • Access analyzer role + findings alarm
  • SNS topic for root account alerts

Monitoring — CC7.1

  • CloudWatch alarms: root login, public bucket detection
  • AWS Config recorder — all resource types
  • Config rules: S3 public read prohibited, S3 encryption required, root MFA

Incident Response — CC7.3

  • CloudWatch log group for security events (365-day retention)
  • Log metric filters: unauthorized API calls, console sign-in failures
  • CloudWatch alarms wired to SNS

Availability — A1.1

  • Versioned availability logs bucket
  • Public access blocked
  • Backup IAM role

Config — CC7.1 + CC7.2

  • AWS Config recorder + delivery channel
  • 3 managed Config rules

Change Management — CC8.1

  • All resources IaC-controlled via Terraform
  • Config recorder status tracking
  • CI/CD gate on every PR

Auto-Remediation

Auto-Remediation Engine

When drift is detected, CloudCompliance closes the loop automatically:

  • LOW RISK — patches resources instantly (tags, labels)
  • HIGH RISK — opens a GitHub PR with exact fix for human review
  • CRITICAL — alerts immediately with remediation steps
$ cloudcompliance drift
🟡 HIGH  cloudcompliance-encrypted-data  DELETED

$ cloudcompliance remediate
📋 PR opened: https://github.com/KADHIRAVANEG/cloudcompliance/pull/32
Remediation log saved → compliance/remediation_log.json

Multi-Channel Alerting & Webhooks

Configure any or all webhook endpoints in .env to receive real-time notifications:

# Slack incoming webhook
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/your/slack/webhook

# Microsoft Teams connector webhook (MessageCard)
TEAMS_WEBHOOK_URL=https://company.webhook.office.com/webhookb2/your/teams/webhook

# Discord channel webhook (Rich Embeds)
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your/discord/webhook

# Generic / PagerDuty / Datadog webhook
GENERIC_WEBHOOK_URL=https://events.pagerduty.com/v2/enqueue

CloudCompliance broadcasts alerts simultaneously across all configured channels for:

  • ✅ Compliance report generated with score, control counts, and status
  • ⚠️ Drift detected — with resource details, drift type, and severity
  • 🔧 Remediation PR opened — with direct GitHub PR review link
  • ✅ Infrastructure in sync confirmation

Scheduled Drift Detection

Drift Detection Report

Run drift detection automatically every hour:

# Run every 60 minutes (default)
cloudcompliance schedule

# Run every 30 minutes
cloudcompliance schedule --interval 30

# Against real AWS
cloudcompliance schedule --endpoint "" --interval 60

Sends Slack alert automatically when drift is found.

AI Compliance Assistant

AI Compliance Assistant

Powered by NVIDIA NIM. Reads your actual tfstate and compliance reports.

export NVIDIA_API_KEY="your-key"

$ cloudcompliance ask "am I ready for a SOC2 audit?"

> Your compliance score is 100% (10/10 controls passing).
> One drift finding detected: encrypted S3 bucket deleted.
> Recommend: run 'cloudcompliance remediate' to open a fix PR.

Compliance Score History

Compliance Score History Timeline

SOC2 Type II requires evidence over time. Every report run is saved automatically.

$ cloudcompliance history

Date              Score   Controls   Trend
2026-07-01        70%     7/10       —
2026-07-07        90%     9/10       ↑ +20%
2026-07-12        100%    10/10      ↑ +10%

$ cloudcompliance history --export
# Exports history_export.json for auditors

Environment Setup

Copy .env.example to .env and fill in your values:

cp .env.example .env
# Required for AI assistant
NVIDIA_API_KEY=your-nvidia-nim-key

# Required for auto-remediation PRs
GITHUB_TOKEN=your-github-token
GITHUB_REPO=KADHIRAVANEG/cloudcompliance

# LocalStack endpoint (leave as-is for local dev)
LOCALSTACK_ENDPOINT=http://localhost:4566

CI/CD Compliance Gate

Every pull request automatically runs:

  1. Terraform Validate — format + syntax check
  2. Checkov Security Scan — 500+ security rules
  3. SOC2 Compliance Check — deploys to LocalStack, runs report, blocks if score < 100%

Project Structure

cloudcompliance/
├── terraform/
│   ├── main.tf
│   ├── variables.tf
│   ├── local.tfvars           # LocalStack config
│   ├── prod.tfvars            # Real AWS config
│   └── modules/
│       ├── networking/        # CC6.1 — VPC, subnets, flow logs
│       ├── logging/           # CC7.2 — Audit bucket
│       ├── encryption/        # CC6.7 — KMS, encrypted S3
│       ├── iam/               # CC6.2 — Password policy, roles
│       ├── monitoring/        # CC7.1 — CloudWatch alarms
│       ├── config/            # CC7.1 + CC7.2 — Config rules
│       ├── incident_response/ # CC7.3 — Log metric filters
│       ├── access_analyzer/   # CC6.3 — IAM access analyzer
│       └── availability/      # A1.1 — Versioning, backup
├── cloudcompliance/
│   ├── cli.py                 # Central CLI router
│   ├── controls.json          # Abstracted mappings (SOC2, HIPAA, PCI-DSS)
│   ├── report.py              # Evidence generator engine
│   ├── history.py             # Score timeline (SQLite)
│   ├── assistant.py           # AI compliance assistant
│   ├── dashboard.py           # Live dashboard (FastAPI)
│   ├── lambda_handler.py      # AWS Lambda event-driven scanner
│   ├── opa.py                 # OPA/Rego custom policy engine
│   ├── drift/
│   │   └── detector.py        # Drift detection engine
│   └── remediation.py         # Auto-remediation engine (generates import blocks)
├── compliance/                # Ignored Generated artifacts (.md, .json, .db)
├── terraform/
│   └── modules/
│       ├── event_driven_scanning/ # Lambda + EventBridge serverless setup
│       └── ...
├── tests/                     # Pytest suite
├── docs/                      # Project website (GitHub Pages)
├── scripts/
│   └── start.sh               # One-command startup
├── .github/workflows/         # CI/CD gate
├── .env.example               # Environment variables template
└── Makefile

Chart

flowchart TD
    %% Styling Definitions
    classDef infra fill:#2980b9,stroke:#fff,color:#fff;
    classDef module fill:#34495e,stroke:#fff,color:#fff;
    classDef glue fill:#f39c12,stroke:#000,color:#000;
    classDef core fill:#27ae60,stroke:#fff,color:#fff;

    %% Orchestration Layer
    MK[Makefile]:::glue
    CI[.github/workflows/]:::glue

    %% Terraform Root
    TF_Root[terraform/]:::infra
    TF_Root --> Main[main.tf]
    TF_Root --> Mod[modules/]:::module

    %% Module Layer & SOC2 Mapping
    Mod --> N[networking - CC6.1]:::module
    Mod --> L[logging - CC7.2]:::module
    Mod --> E[encryption - CC6.7]:::module
    Mod --> I[iam - CC6.2]:::module
    Mod --> M[monitoring - CC7.1]:::module
    Mod --> C[config - CC7.1/7.2]:::module
    Mod --> IR[incident_response - CC7.3]:::module
    Mod --> AA[access_analyzer - CC6.3]:::module
    Mod --> AV[availability - A1.1]:::module

    %% Core Logic Layer
    Core[cloudcompliance/]:::core
    Core --> Rep[report.py]
    Core --> Hist[history.py]
    Core --> Asst[assistant.py]
    Core --> Drift[drift/detector.py]
    Core --> Rem[remediation.py]

    %% Connections
    MK -->|deploy| TF_Root
    MK -->|audit| Core
    CI -->|gate| TF_Root
    CI -->|check| Core
    Drift -.-> Rem
    Core -->|outputs| Comp[compliance/]

Makefile Commands

make start          # Start LocalStack + deploy + report + dashboard
make deploy         # Deploy all SOC2 controls to LocalStack
make deploy-prod    # Deploy to real AWS
make validate       # Terraform format + validate
make report         # Generate SOC2 evidence report
make drift          # Run drift detection
make history        # Show score history
make history-export # Export audit evidence JSON
make remediate      # Auto-remediate drift findings
make remediate-dry  # Preview remediation without changes
make serve          # Open live dashboard at :8080
make destroy        # Tear down all infrastructure
make all            # deploy + report + drift + history

Use as a Terraform Module

module "soc2_baseline" {
  source  = "KADHIRAVANEG/cloudcompliance/aws"
  version = "1.5.0"

  project_name = "my-startup"
  environment  = "prod"
  aws_region   = "us-east-1"
}

Install Options

# Python CLI (recommended)
pip install cloudcompliance

# Docker
docker pull ghcr.io/joker-53/cloudcompliance:latest
docker run -v ~/cloudcompliance/terraform:/app/terraform \
  ghcr.io/joker-53/cloudcompliance:latest

# Terraform Registry
source  = "KADHIRAVANEG/cloudcompliance/aws"
version = "1.5.0"

LocalStack vs Real AWS

Feature LocalStack (free) Real AWS
VPC / Subnets ✅ ✅
S3 + Encryption ✅ ✅
KMS ✅ ✅
IAM ✅ ✅
CloudWatch ✅ ✅
AWS Config ✅ ✅
SNS ✅ ✅
CloudTrail ⚠️ Pro only ✅
GuardDuty ⚠️ Pro only ✅

Standards Referenced


Tech Stack

Terraform · Python · FastAPI · AWS · Azure · GCP · LocalStack · GitHub Actions · NVIDIA NIM · SQLite · OPA/Rego · pytest


Changelog

Version What's new
v2.1.0 Executive auditor PDF report (--pdf), GitHub PR compliance bot & action (pr-check), Live agentless AWS scanner (scan --live), and interactive web dashboard controls (on-demand drift & audit bundle zip download)
v2.0.0 Multi-cloud, HIPAA/PCI-DSS, OPA/Rego custom policies, S3 remote state, TF 1.5 import generation, and EventBridge real-time scanning
v1.6.0 Slack notifications + scheduled drift detection
v1.5.0 Live dashboard — cloudcompliance serve
v1.4.0 Auto-remediation — GitHub PR for high-risk drift
v1.3.0 Compliance score history — SOC2 Type II evidence
v1.2.0 Drift detection — cloudcompliance drift
v1.1.0 10 SOC2 controls, 46 resources, markdown reports
v1.0.0 Initial release — SOC2 baseline IaC

Author

Kadhiravan E.G. — Cybersecurity student
GitHub: @KADHIRAVANEG
Website: CloudCompliance

Metadata

Release files for cloudcompliance 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloudcompliance 2.3.0
File Size Uploaded Provenance Actions
cloudcompliance-2.3.0.tar.gz 81.4 kB Without provenance Details for cloudcompliance-2.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cloudcompliance 2.3.0
File Interpreter ABI Platform Actions
cloudcompliance-2.3.0-py3-none-any.whl Python 3 none any Details for cloudcompliance-2.3.0-py3-none-any.whl

Total release size: 154.5 kB

Release files / cloudcompliance-2.3.0.tar.gz

Download URL cloudcompliance-2.3.0.tar.gz
Size 81.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8649fb36e45e80ed0edf077957144d5617e85b27c09376a17b93ef6ab07e4eaf
BLAKE2b-256 checksum
How to use checksums
d8310f52a4da18ab68742acd77d4c5741379c3a19a0dd7b766a28967c80b2e05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / cloudcompliance-2.3.0-py3-none-any.whl

Download URL cloudcompliance-2.3.0-py3-none-any.whl
Size 73.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3efdefa1ac4e964caabf56b483e19da299ed3e570dc5aa941f1136efac0d396
BLAKE2b-256 checksum
How to use checksums
be9a49e5e2baebb32a47f0e569f7daae2497a9a5548ac2fd0dcd368534c598d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for cloudcompliance 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page