# Infrastructure Documentation

This directory contains comprehensive documentation for the Lilith platform
infrastructure.

## Contents

| Document                                      | Description                                     |
| --------------------------------------------- | ----------------------------------------------- |
| [AWS Setup](./aws-setup.md)                   | AWS account structure, IAM, cost management     |
| [Networking](./networking.md)                 | VPC architecture, subnets, security groups      |
| [EKS](./eks.md)                               | Kubernetes cluster configuration and management |
| [Secrets Management](./secrets-management.md) | HashiCorp Vault and secrets handling            |

## Quick Links

### Deployment

- [Terraform Guide](../../deploy/terraform/README.md) - Infrastructure as code
- [Kubernetes Deployment](../../deploy/terraform/DEPLOYMENT.md) - Full
  deployment guide
- [Helm Charts](../../deploy/helm/) - Application deployment

### Operations

- [Scaling Runbook](../runbooks/procedures/scaling.md) - Manual and auto-scaling
- [Deployment Runbook](../runbooks/procedures/deployment.md) - Deployment
  procedures
- [Monitoring](../runbooks/procedures/monitoring.md) - Observability stack

### Security

- [Access Control](../security/ACCESS_CONTROL.md) - RBAC and permissions
- [Threat Model](../security/THREAT_MODEL.md) - Security analysis
- [Audit Logging](../security/AUDIT_LOGGING.md) - Compliance logging

## Architecture Overview

```
┌─────────────────────────────────────────────────────────────────────────┐
│                              AWS Cloud                                   │
│  ┌───────────────────────────────────────────────────────────────────┐  │
│  │                        VPC (10.0.0.0/16)                          │  │
│  │  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐            │  │
│  │  │ Public Sub   │  │ Private Sub  │  │ Database Sub │            │  │
│  │  │ (ALB, NAT)   │  │ (EKS Nodes)  │  │ (RDS, Redis) │            │  │
│  │  └──────────────┘  └──────────────┘  └──────────────┘            │  │
│  │                           │                                       │  │
│  │  ┌────────────────────────▼────────────────────────────────────┐ │  │
│  │  │                     EKS Cluster                              │ │  │
│  │  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐           │ │  │
│  │  │  │  BFF    │ │  Auth   │ │ Content │ │   AI    │           │ │  │
│  │  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘           │ │  │
│  │  │  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐           │ │  │
│  │  │  │ Istio   │ │ Vault   │ │ ArgoCD  │ │Prometheus│          │ │  │
│  │  │  └─────────┘ └─────────┘ └─────────┘ └─────────┘           │ │  │
│  │  └──────────────────────────────────────────────────────────────┘ │  │
│  └───────────────────────────────────────────────────────────────────┘  │
│                                                                          │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐    │
│  │   Route53   │  │     S3      │  │     KMS     │  │  CloudWatch │    │
│  │    (DNS)    │  │  (Storage)  │  │ (Encryption)│  │ (Monitoring)│    │
│  └─────────────┘  └─────────────┘  └─────────────┘  └─────────────┘    │
└─────────────────────────────────────────────────────────────────────────┘
```

## Environment Matrix

| Component        | Development | Staging        | Production     |
| ---------------- | ----------- | -------------- | -------------- |
| EKS Version      | 1.28        | 1.28           | 1.28           |
| Node Count       | 2-5         | 3-10           | 6-30           |
| RDS Instance     | db.t3.micro | db.t3.small    | db.r5.large    |
| Redis            | Single node | 3-node cluster | 6-node cluster |
| Multi-AZ         | No          | Yes            | Yes            |
| Backup Retention | 1 day       | 7 days         | 30 days        |

## Getting Started

1. **Set up AWS credentials**

   ```bash
   aws configure --profile lilith-dev
   ```

2. **Bootstrap Terraform state**

   ```bash
   cd deploy/terraform/backend-bootstrap
   terraform init && terraform apply
   ```

3. **Deploy infrastructure**

   ```bash
   cd deploy/terraform
   terraform init -backend-config=backend.hcl
   terraform plan -var-file=terraform.tfvars
   terraform apply
   ```

4. **Configure kubectl**
   ```bash
   aws eks update-kubeconfig --name lilith-dev --region us-east-1
   ```

## Support

For infrastructure issues:

- Slack: #platform-oncall
- Email: platform@lilith.app
