Production-ready AWS security baseline for the EU β NIS2, DORA, ISO 27001, BSI IT-Grundschutz.
The only open-source Terraform framework that covers NIS2 Articles 21β32, DORA Article 16, and BSI IT-Grundschutz out of the box β built for German Mittelstand and EU critical infrastructure.
π©πͺ Deutsche Version | π¬π§ English Version
# Prerequisites: terraform >= 1.5, aws-cli >= 2.13, opa >= 0.68
bash install/linux.sh # Linux / Linux Mint
bash install/macos.sh # macOS
# Windows: .\install\windows.ps1
# Deploy
git clone https://github.com/Protector080322/terraform-aws-security
cd terraform-aws-security
cp examples/mittelstand-sme/terraform.tfvars .
make validate # NIS2/DORA compliance check
make plan # Preview changes
make apply # Deploy (requires confirmation)| You are... | This gives you... |
|---|---|
| German Mittelstand IT team | NIS2-compliant AWS baseline in under 1 hour |
| Security Architect (EU) | 35+ controls mapped to NIS2/DORA/ISO 27001 |
| vCISO / Compliance Lead | Automated evidence generation & BSI-ready reports |
| DevOps Engineer | Policy-as-Code pipeline blocking non-compliant deploys |
| Auditor / Pen Tester | Ready-made OPA policies for infrastructure review |
The problem: NIS2 became mandatory in Germany in October 2024. DORA in January 2025. Most AWS environments are NOT compliant. Manual compliance is expensive, slow, and error-prone.
The solution: Infrastructure-as-Code + Policy-as-Code = compliance at the speed of deployment.
Traditional compliance: manual audit β 3 months β β¬50k+
This framework: terraform apply β 5 minutes β automated evidence
| Framework | Articles | Status | Who Needs It |
|---|---|---|---|
| πͺπΊ NIS2 (EU 2022/2555) | 21, 23, 25, 28, 32 | β Full | All EU essential/important operators |
| π¦ DORA (EU 2022/2554) | 16 (incident reporting) | β Implemented | Banks, insurance, investment firms |
| π ISO 27001:2022 | A.5βA.18 (35+ controls) | β Mapped | Any security-conscious organization |
| π©πͺ BSI IT-Grundschutz | ORP.4, CON.1, DER.2.1, NET.1.1 | β Aligned | German organizations |
| π GDPR | Data residency (EU-DE) | β Configured | All EU data processors |
| π TISAX | VDA ISA 6.0 | β Example | Automotive suppliers |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AWS Organization β
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
β β Management β β Production β β Audit Account β β
β β Account β β Account β β β β
β β SCPs β β EKS/k3s β β CloudTrail β β
β β GuardDuty β β RDS (enc.) β β S3 (locked) β β
β β SecurityHubβ β VPC β β KMS β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
NIS2 Art.21 NIS2 Art.32 NIS2 Art.25
(Access Control) (Network Security) (Audit Logging)
See ARCHITECTURE.md for full Mermaid diagrams.
NIS2 Article 21 β Access Control
- MFA enforcement (deny all actions without MFA)
- Permission boundaries on all IAM roles/users
- Break-glass PAM role (emergency access, 15-min MFA window)
- Session timeout: 8 hours maximum
- Access key rotation: 90-day AWS Config rule
- No root access key (Config rule)
- RBAC: auditor read-only role
NIS2 Article 23 β Incident Detection & Response
- GuardDuty (ML-based threat detection, EKS audit logs)
- Security Hub (CIS 1.4.0 + AFSBP + NIST centralized findings)
- Lambda incident response playbook (auto-classifies, notifies BSI)
- EventBridge: GuardDuty HIGH/CRITICAL β Lambda β SNS
- CloudWatch alarms: root login, MFA disable, GuardDuty disable
- DORA Step Functions: 4h β 72h β 1-month BaFin reporting
NIS2 Article 25 β Audit Logging & Encryption
- CloudTrail: multi-region, log file validation, KMS encrypted
- S3 Object Lock: tamper-proof logs, GOVERNANCE mode, 365 days
- S3 lifecycle: STANDARD_IA (90d) β Glacier (365d) β delete (7yr)
- KMS: dedicated key, automatic annual rotation
- All S3 buckets: KMS encryption (not AES256)
- RDS: encrypted storage (Config rule)
- EBS: encrypted volumes (Config rule)
NIS2 Article 28 β Supply Chain & Data Residency
- EU-only regions: eu-central-1 (Frankfurt) + eu-west-1 (Ireland)
- Terraform variable validation:
startswith(var.region, "eu-") - SCP: deny CloudTrail disable
- SCP: deny GuardDuty disable
- SCP: deny Security Hub disable
- SCP: deny S3 public access
NIS2 Article 32 β Network Segmentation
- k3s NetworkPolicies: default-deny-ingress
- IMDSv2 required on all EC2 (SSRF protection)
- No public IPs on backend instances
- VPC flow logs (Config rule)
- Lambda in VPC (Config rule)
- SSH/RDP blocked from internet (OPA rule)
terraform-aws-security/
βββ π envs/
β βββ dev/ # 7-step deployment (stateβloggingβconfigβsecurityβpacβscpsβiam)
β βββ prod/ # Production mirror
βββ π modules/
β βββ logging/ # CloudTrail + KMS + S3
β βββ iam/ # Permission boundaries + MFA
β βββ config/ # AWS Config + conformance packs
β βββ org/scps/ # Organization SCPs
βββ π compliance/
β βββ nis2/ # Articles 21, 23, 25 (Terraform)
β βββ dora/ # Article 16 Step Functions workflow
βββ π examples/
β βββ mittelstand-sme/ # German manufacturing, ~500 employees
β βββ healthcare/ # GDPR Art.9 + NIS2 essential
β βββ automotive/ # TISAX + ISO-SAE-21434
βββ π kubernetes/
β βββ k3s-hardened/ # NIS2 Art.21/32 hardened cluster
βββ π policies-as-code/
β βββ opa/ # 20+ NIS2/DORA/ISO 27001 OPA rules
βββ π install/
β βββ macos.sh # One-command setup for macOS
β βββ linux.sh # One-command setup for Linux
β βββ windows.ps1 # One-command setup for Windows
βββ π scripts/
β βββ validate-compliance.sh # Pre-deploy check
β βββ generate-report.sh # Compliance report generator
βββ π docs/
β βββ compliance-mapping.md # 35+ controls mapped
βββ Makefile # make validate / plan / apply / report
βββ ARCHITECTURE.md # 7 Mermaid diagrams
βββ GETTING_STARTED.md # 5-minute setup guide
βββ CHANGELOG.md # Version history
Every pull request runs:
terraform fmt β terraform validate
β
tfsec (HIGH+) β checkov
β
OPA unit tests β OPA plan eval
β
gitleaks (secrets scan)
β
terraform plan (with OPA validation)
β
compliance report
β
terraform apply (main branch only, after approval)
# German Mittelstand (manufacturing, ~500 employees)
cp examples/mittelstand-sme/terraform.tfvars .
# Healthcare (GDPR Art.9 + NIS2 essential operator)
cp examples/healthcare/terraform.tfvars .
# Automotive (TISAX + VDA ISA 6.0 + NIS2)
cp examples/automotive/terraform.tfvars .- GETTING_STARTED.md β 5-minute quick start
- ARCHITECTURE.md β Diagrams & topology
- compliance/nis2/README.md β NIS2 guide
- compliance/dora/README.md β DORA guide
- docs/compliance-mapping.md β Control mapping
- install/README.md β OS-specific setup
# Voraussetzungen: terraform >= 1.5, aws-cli >= 2.13
bash install/linux.sh # Linux / Linux Mint
bash install/macos.sh # macOS
# Deployment
git clone https://github.com/Protector080322/terraform-aws-security
cd terraform-aws-security
cp examples/mittelstand-sme/terraform.tfvars .
make validate # NIS2/DORA Compliance-PrΓΌfung
make plan && make apply # Infrastruktur deployenDas Problem: Die NIS2-Richtlinie ist seit Oktober 2024 in Deutschland verbindlich. DORA seit Januar 2025. Die meisten AWS-Umgebungen sind nicht konform. Manuelle Compliance kostet Zeit und Geld.
Die LΓΆsung: Infrastructure-as-Code + Policy-as-Code = Compliance mit jedem Deployment automatisch sichergestellt.
| BSI-Baustein | Beschreibung | Implementierung |
|---|---|---|
| ORP.4 | IdentitΓ€ts- & Zugriffsmanagement | modules/iam/ |
| CON.1 | Kryptokonzept | modules/logging/ (KMS) |
| OPS.1.1.5 | Datensicherung | AWS Backup + S3 Object Lock |
| DER.2.1 | Incident Management | compliance/nis2/article-23-incident-response.tf |
| NET.1.1 | Netzarchitektur | kubernetes/k3s-hardened/ |
| INF.14 | Automatisierungsnetze | compliance/nis2/article-32-network-security.tf |
| Vorfall | Frist | BehΓΆrde |
|---|---|---|
| Erheblicher Sicherheitsvorfall | 24 Stunden (Erstmeldung) | BSI |
| VollstΓ€ndige Meldung | 72 Stunden | BSI |
| Abschlussbericht | 1 Monat | BSI |
| BSI Meldung: | https://www.bsi.bund.de |
- Mittelstand (Fertigung, Maschinenbau, Automobilzulieferer)
- Gesundheitswesen (KrankenhΓ€user, Pharmaunternehmen)
- Finanzsektor (DORA-pflichtige Unternehmen)
- Kritische Infrastruktur (KRITIS-Betreiber)
- IT-Dienstleister fΓΌr die oben genannten
See CONTRIBUTING.md β we welcome:
- New NIS2/DORA article implementations
- Additional industry examples (energy, finance, healthcare)
- Improved OPA policies
- Bug fixes and documentation
MIT License β free to use, modify, and distribute.
Ruzibaev007 Berlin, Germany | Security Architect | NIS2 | AWS | Terraform
π§ z.ruzibaev@mail.de π GitHub
Built for German Mittelstand. Compliant with EU regulations. Open source.