Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OWASP/Nest/llms.txt
Use this file to discover all available pages before exploring further.
Overview
OWASP Nest infrastructure is provisioned on AWS using Terraform modules. The setup includes VPC networking, ECS clusters, RDS PostgreSQL, ElastiCache Redis, Application Load Balancers, Lambda functions via Zappa, and S3 storage.Prerequisites
- AWS Account: With appropriate permissions
- Terraform: Install Terraform
- AWS CLI: Install AWS CLI
- Docker: For building and pushing images to ECR
- Python Poetry: For Zappa deployment
- Project Setup: Complete CONTRIBUTING.md
Terraform Modules
The infrastructure is organized into modular components:Core Modules
alb: Application Load Balancer for frontend and backendcache: ElastiCache Redis for session and task queuedatabase: RDS PostgreSQL 16 with pgvector extensionecs: Elastic Container Service for frontend and worker tasksfrontend: CloudFront and S3 for static assetskms: KMS keys for encryption at restnetworking: VPC, subnets, NAT gateways, and endpointsparameters: AWS Systems Manager Parameter Store for secretssecurity: Security groups and IAM rolesstorage: S3 buckets for fixtures, logs, and backups
Submodules
ecs/task: ECS task definitions for migrate, load-data, index-datanetworking/nacl: Network ACLs for subnet-level securitynetworking/vpc-endpoint: VPC endpoints for AWS servicesstorage/s3-bucket: Reusable S3 bucket configuration
Architecture Diagram
Setup Instructions
Step 1: Setup Terraform State (One-Time)
Create S3 backend for Terraform state management.Create IAM User
Createnest-state IAM user with policies defined in infrastructure/state/README.md.
Initialize State Backend
Step 2: Bootstrap IAM Role
Create the IAM role that Terraform will assume for infrastructure deployment.Create IAM User
Createnest-bootstrap IAM user with policies from infrastructure/bootstrap/README.md.
Configure Bootstrap
terraform.tfvars:
Configure Backend
terraform.tfbackend with the bootstrap bucket name from Step 1:
Apply Bootstrap
nest-staging-terraform IAM role.
Step 3: Setup Staging Infrastructure
Create IAM User
Createnest-staging IAM user with policies from infrastructure/staging/README.md.
This user must assume the nest-staging-terraform role created in Step 2.
Configure AWS Credentials
Add to~/.aws/credentials:
~/.aws/config:
Configure Staging
terraform.tfbackend with staging state bucket:
terraform.tfvars with your configuration:
Apply Infrastructure
- VPC with public/private subnets
- RDS PostgreSQL database
- ElastiCache Redis cluster
- ECS clusters and task definitions
- Application Load Balancers
- S3 buckets
- KMS keys
- Security groups and IAM roles
Step 4: Populate Secrets
Navigate to AWS Console → Systems Manager → Parameter Store. Populate all parameters withto-be-set-in-aws-console value:
DJANGO_SECRET_KEYDJANGO_ALGOLIA_APPLICATION_IDDJANGO_ALGOLIA_WRITE_API_KEYDJANGO_OPEN_AI_SECRET_KEYDJANGO_SLACK_BOT_TOKENDJANGO_SLACK_SIGNING_SECRETDJANGO_SENTRY_DSNGITHUB_TOKENNEXTAUTH_SECRETNEXT_SERVER_GITHUB_CLIENT_IDNEXT_SERVER_GITHUB_CLIENT_SECRET
Deploy Backend with Zappa
The Django backend runs on AWS Lambda via Zappa.1. Install Dependencies
2. Configure Zappa
zappa_settings.json and replace all ${...} variables with Terraform outputs:
${vpc_id}→ fromvpc_idoutput${private_subnet_ids}→ fromprivate_subnet_idsoutput${lambda_security_group_id}→ fromlambda_security_group_idoutput${lambda_role_arn}→ fromlambda_role_arnoutput
3. Deploy Lambda
5xx errors:
4. Configure ALB Routing
Get Lambda details:infrastructure/staging/terraform.tfvars:
Populate ECR Repositories
Build and push Docker images to Elastic Container Registry.1. Login to ECR
2. Build and Push Backend Image
3. Build and Push Frontend Image
Setup Database
1. Upload Fixture to S3
Get the fixtures bucket name from Terraform output:2. Run ECS Tasks
Navigate to AWS Console → ECS → Task Definitions. Run tasks in this order:a. Run Migrations
- Select
nest-staging-migratetask definition - Deploy → Run Task
- Configuration:
- Cluster:
nest-staging-tasks-cluster - VPC:
nest-staging-vpc - Security Group:
nest-staging-ecs-sg
- Cluster:
- Create and monitor logs
b. Load Data
- Select
nest-staging-load-datatask definition - Deploy → Run Task
- Use same cluster, VPC, and security group
- Monitor completion
c. Index Data
- Select
nest-staging-index-datatask definition - Deploy → Run Task
- Use same configuration
- Verify Algolia indices are populated
Configure Domain and Frontend
1. Validate ACM Certificate
Get DNS validation records:2. Point Domain to ALB
Get ALB DNS name:3. Update Frontend Parameters
Get Lambda URL:NEXT_SERVER_GRAPHQL_URL→ Lambda URL +/graphql/NEXT_SERVER_CSRF_URL→ Lambda URL +/csrf/
4. Restart Frontend ECS Service
Monitoring and Maintenance
View Lambda Logs
Update Lambda
View ECS Logs
Navigate to AWS Console → ECS → Clusters → Tasks → Logs.Database Backups
RDS automated backups are enabled by default. Manual snapshot: AWS Console → RDS → Databases → nest-staging-db → Actions → Take SnapshotCleaning Up
Cost Optimization
- RDS: Use
db.t3.mediumfor staging, scale up for production - ElastiCache: Use
cache.t3.mediumor smaller for development - Lambda: Pay per request, no idle costs
- ECS: Use Fargate Spot for non-critical tasks
- S3: Enable lifecycle policies for log rotation
- NAT Gateway: Expensive - consider VPC endpoints for AWS services
Security Best Practices
- Use Parameter Store for all secrets (encrypted with KMS)
- Enable VPC Flow Logs for network monitoring
- Restrict Security Groups to minimum required ports
- Enable RDS encryption at rest (KMS)
- Enable S3 versioning for critical buckets
- Use IAM roles instead of access keys where possible
- Enable CloudTrail for audit logging
- Rotate secrets regularly in Parameter Store