Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
/**
* AiSOC - AI Security Operations Center
* Terraform Infrastructure - Main Configuration
* AiSOC — open-source under MIT License
*/
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.23"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.11"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
backend "s3" {
bucket = "aisoc-terraform-state"
key = "infra/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "aisoc-terraform-locks"
}
}
provider "aws" {
region = var.aws_region
default_tags {
tags = {
Project = "AiSOC"
Environment = var.environment
ManagedBy = "Terraform"
Owner = "AiSOC"
}
}
}
# ─── Data Sources ─────────────────────────────────────────────────────────────
data "aws_availability_zones" "available" {
state = "available"
}
data "aws_caller_identity" "current" {}
# ─── Locals ───────────────────────────────────────────────────────────────────
locals {
name_prefix = "aisoc-${var.environment}"
azs = slice(data.aws_availability_zones.available.names, 0, 3)
account_id = data.aws_caller_identity.current.account_id
}
# ─── Modules ──────────────────────────────────────────────────────────────────
module "vpc" {
source = "./modules/vpc"
name_prefix = local.name_prefix
vpc_cidr = var.vpc_cidr
availability_zones = local.azs
public_subnets_cidr = var.public_subnets_cidr
private_subnets_cidr = var.private_subnets_cidr
db_subnets_cidr = var.db_subnets_cidr
}
module "eks" {
source = "./modules/eks"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
private_subnet_ids = module.vpc.private_subnet_ids
cluster_version = var.eks_cluster_version
node_groups = {
general = {
instance_types = ["m6i.xlarge"]
min_size = 2
max_size = 10
desired_size = 3
disk_size = 50
}
compute = {
instance_types = ["c6i.2xlarge"]
min_size = 0
max_size = 5
desired_size = 1
disk_size = 100
taints = [{
key = "workload"
value = "compute"
effect = "NO_SCHEDULE"
}]
}
}
}
module "rds" {
source = "./modules/rds"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
db_subnet_ids = module.vpc.db_subnet_ids
instance_class = var.rds_instance_class
db_name = "aisoc"
db_username = var.db_username
allowed_security_groups = [module.eks.node_security_group_id]
}
# ─── The runtime database role ────────────────────────────────────────────────
#
# RDS creates one master user, and handing it to every service is what left the
# schema's 92 row-level-security policies filtering nothing: a superuser
# ignores them even under FORCE ROW LEVEL SECURITY. Services connect as the
# DML-only role that `services/api/migrations/061_runtime_app_role.sql` creates;
# the master user is kept for migrations.
#
# The password is generated here rather than written down anywhere. Feed it to
# the job that applies the migration chain as AISOC_APP_DB_PASSWORD — that run
# is what gives the role a login — and read it back with
# `terraform output -raw db_app_password`.
resource "random_password" "db_app" {
length = 32
special = false
}
module "elasticache" {
source = "./modules/elasticache"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnet_ids
node_type = var.redis_node_type
num_shards = 2
replicas_per_shard = 1
allowed_security_groups = [module.eks.node_security_group_id]
}
module "kafka" {
source = "./modules/kafka"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnet_ids
instance_type = var.kafka_instance_type
broker_count = 3
allowed_security_groups = [module.eks.node_security_group_id]
}
module "osquery_tls" {
source = "./modules/osquery-tls"
namespace = "aisoc"
create_namespace = false
image_repository = "ghcr.io/aisoc-community/osquery-tls"
image_tag = var.osquery_tls_image_tag
replicas = var.osquery_tls_replicas
enroll_secret = var.osquery_tls_enroll_secret
# The runtime role, not the RDS master user. See random_password.db_app above.
database_url = "postgresql+asyncpg://${var.db_app_username}:${random_password.db_app.result}@${module.rds.endpoint}/aisoc"
ingest_base_url = "http://aisoc-ingest.aisoc.svc.cluster.local:8080"
autoscaling = {
enabled = true
min_replicas = var.osquery_tls_replicas
max_replicas = var.osquery_tls_replicas * 5
target_cpu_utilization = 70
}
}
# ─── Outputs ──────────────────────────────────────────────────────────────────
output "eks_cluster_name" {
description = "EKS cluster name"
value = module.eks.cluster_name
}
output "eks_cluster_endpoint" {
description = "EKS cluster API endpoint"
value = module.eks.cluster_endpoint
sensitive = true
}
output "rds_endpoint" {
description = "PostgreSQL RDS endpoint"
value = module.rds.endpoint
sensitive = true
}
output "redis_endpoint" {
description = "Redis cluster endpoint"
value = module.elasticache.endpoint
sensitive = true
}
output "kafka_bootstrap_servers" {
description = "Kafka bootstrap servers"
value = module.kafka.bootstrap_brokers
sensitive = true
}
output "vpc_id" {
description = "VPC ID"
value = module.vpc.vpc_id
}
output "db_app_password" {
description = "Password for the DML-only runtime role. Supply as AISOC_APP_DB_PASSWORD to the migration job."
value = random_password.db_app.result
sensitive = true
}
output "database_migration_url" {
# aisoc-db-role: owner — the migration chain needs DDL; the runtime role has none
description = "DSN for DATABASE_MIGRATION_URL. The RDS master user, used for DDL only."
value = "postgresql+asyncpg://${var.db_username}:${module.rds.db_password}@${module.rds.endpoint}/aisoc"
sensitive = true
}
output "osquery_tls_internal_url" {
description = "In-cluster URL for the osquery-tls TLS endpoint"
value = module.osquery_tls.internal_url
}