Skip to content

Latest commit

 

History

History
539 lines (413 loc) · 16.5 KB

File metadata and controls

539 lines (413 loc) · 16.5 KB

Sentinel Infrastructure Deployment Guide

This guide covers the deployment of the Sentinel Cybersecurity Triage Platform infrastructure using AWS CloudFormation with a modular stack approach.

Overview

The Sentinel platform consists of several AWS services working together to provide automated cybersecurity news ingestion, analysis, and triage capabilities. The infrastructure is now split into 5 modular CloudFormation stacks for better management and deployment flexibility.

Stack Architecture

The infrastructure is organized into the following stacks:

  1. Core Stack (01-core-stack.yaml)

    • KMS encryption keys
    • Artifacts S3 bucket (for Lambda packages)
    • Random suffix generator for unique naming
    • Foundation resources needed by all other stacks
  2. Storage Stack (02-storage-stack.yaml)

    • DynamoDB tables (Articles, Comments, Memory)
    • S3 buckets (Content, Traces)
    • CloudWatch log groups
    • Data persistence layer
  3. Backend Services Stack (03-backend-services-stack.yaml)

    • Lambda functions (all processing logic)
    • Step Functions state machine
    • IAM roles for Lambda execution
    • Core application logic
  4. AI/Bedrock Stack (04-ai-bedrock-stack.yaml)

    • OpenSearch Serverless collection
    • Bedrock Knowledge Base
    • Bedrock Agents
    • AI/ML components
  5. API & Auth Stack (05-api-auth-stack.yaml)

    • Cognito User Pool and Identity Pool
    • API Gateway REST API
    • Amplify web application
    • CloudWatch dashboard
    • User-facing components

Architecture Components

  • Data Storage: DynamoDB tables for articles, comments, and memory
  • File Storage: S3 buckets for content, artifacts, and traces
  • Compute: Lambda functions for processing logic
  • Orchestration: Step Functions for workflow management
  • AI/ML: Bedrock agents and knowledge bases for intelligent processing
  • Search: OpenSearch Serverless for vector similarity search
  • Authentication: Cognito for user management
  • API: API Gateway for REST endpoints
  • Frontend: Amplify for web application hosting
  • Monitoring: CloudWatch for logging and metrics

Prerequisites

Before deploying the infrastructure, ensure you have:

  1. AWS CLI installed and configured with appropriate credentials
  2. Sufficient AWS permissions to create the required resources
  3. AWS Bedrock access enabled in your account and region
  4. Domain/Email setup for SES notifications (optional)
  5. Git repository for Amplify deployment (optional)
  6. jq installed for JSON processing (used in delete script)

Required AWS Permissions

Your AWS user/role needs permissions for:

  • CloudFormation (full access)
  • IAM (create/manage roles and policies)
  • S3 (create/manage buckets)
  • DynamoDB (create/manage tables)
  • Lambda (create/manage functions)
  • Step Functions (create/manage state machines)
  • Bedrock (access to models and agents)
  • OpenSearch Serverless (create/manage collections)
  • Cognito (create/manage user pools)
  • API Gateway (create/manage APIs)
  • Amplify (create/manage applications)
  • CloudWatch (create/manage dashboards and logs)
  • KMS (create/manage encryption keys)

Deployment Steps

1. Clone and Prepare

git clone <repository-url>
cd sentinel

2. Configure Parameters

The deployment now uses stack-specific parameter files for better organization:

  • cloudformation/parameters-core.json - Core Stack parameters
  • cloudformation/parameters-storage.json - Storage Stack parameters
  • cloudformation/parameters-backend.json - Backend Services parameters
  • cloudformation/parameters-ai.json - AI/Bedrock Stack parameters
  • cloudformation/parameters-api-auth.json - API & Auth Stack parameters

You can also use the legacy parameters-prod.json file, but the stack-specific files are recommended.

Key parameters to customize:

  • SESenderEmail - Email address for notifications
  • EscalationEmails - Comma-separated list of escalation emails
  • AlertEmails - Comma-separated list of alert emails
  • AmplifyRepositoryUrl - Git repository URL for web app
  • BedrockModelId - Bedrock model for LLM operations
  • RelevanceThreshold - Minimum relevance score (0.0-1.0)

3. Deploy Infrastructure

Using the Deploy Script (Recommended)

cd cloudformation

# Deploy all stacks
./deploy-stacks.sh

# Or deploy Lambda packages separately
./deploy-lambda-packages.sh -e prod -b <artifacts-bucket-name>

# Deploy Lambda packages and recreate storage stack
./deploy-lambda-packages.sh -e prod -b <artifacts-bucket-name> -r

The deployment process:

  1. Validate all CloudFormation templates
  2. Deploy stacks in the correct dependency order:
    • Core Stack (foundation)
    • Package and upload Lambda functions from src/lambda/
    • Storage Stack (data layer)
    • Backend Services Stack (application logic)
    • AI/Bedrock Stack (AI components)
    • API & Auth Stack (user interface)
  3. Display deployment outputs and next steps

Manual Deployment (Advanced)

If you prefer manual control, deploy stacks in this order:

# 1. Deploy Core Stack
aws cloudformation create-stack \
  --stack-name sentinel-prod-core \
  --template-body file://01-core-stack.yaml \
  --parameters file://parameters-prod.json \
  --capabilities CAPABILITY_NAMED_IAM \
  --region us-east-1

# Wait for completion
aws cloudformation wait stack-create-complete \
  --stack-name sentinel-prod-core \
  --region us-east-1

# 2. Package and upload Lambda functions
./deploy-lambda-packages.sh -e prod -b <artifacts-bucket-name>

# 3. Deploy Storage Stack
aws cloudformation create-stack \
  --stack-name sentinel-prod-storage \
  --template-body file://02-storage-stack.yaml \
  --parameters file://parameters-prod.json \
  --capabilities CAPABILITY_NAMED_IAM \
  --region us-east-1

# Continue with remaining stacks...

4. Lambda Function Implementation

The deployment script now uses the actual source code from the src/lambda/ directory. The expected structure is:

src/
├── common/                          # Shared utilities (optional)
│   ├── __init__.py
│   ├── aws_clients.py              # AWS service clients
│   ├── bedrock_utils.py            # Bedrock model utilities
│   └── logging_utils.py            # Logging configuration
└── lambda/
    ├── feed-parser/
    │   ├── lambda_function.py      # Main handler
    │   └── requirements.txt        # Dependencies (optional)
    ├── relevancy-evaluator/
    ├── dedup-tool/
    ├── guardrail-tool/
    ├── storage-tool/
    ├── human-escalation/
    ├── notifier/
    ├── analyst-assistant/
    ├── commentary-api/
    ├── publish-decision/
    ├── query-kb/
    └── opensearch-index-manager/   # Custom resource for OpenSearch

If a function directory doesn't exist, the script creates a placeholder implementation.

5. Verify Deployment

Check the stack outputs for important URLs and identifiers:

# Check all stack outputs
aws cloudformation describe-stacks --stack-name sentinel-prod-core --query 'Stacks[0].Outputs'
aws cloudformation describe-stacks --stack-name sentinel-prod-storage --query 'Stacks[0].Outputs'
aws cloudformation describe-stacks --stack-name sentinel-prod-backend --query 'Stacks[0].Outputs'
aws cloudformation describe-stacks --stack-name sentinel-prod-ai --query 'Stacks[0].Outputs'
aws cloudformation describe-stacks --stack-name sentinel-prod-api-auth --query 'Stacks[0].Outputs'

Post-Deployment Configuration

1. Implement Lambda Functions

Replace the placeholder Lambda functions with actual implementations:

  1. Feed Parser: RSS feed parsing and article extraction
  2. Relevancy Evaluator: AI-powered relevance scoring
  3. Dedup Tool: Semantic deduplication using embeddings
  4. Guardrail Tool: Content policy enforcement
  5. Storage Tool: Article storage and retrieval
  6. Human Escalation: Notification and escalation logic
  7. Notifier: Email and alert notifications
  8. Analyst Assistant: AI chat interface
  9. Commentary API: Article comments and annotations
  10. Publish Decision: Human review decision processing
  11. Query KB: Knowledge base RAG queries

2. Cognito User Setup

Create users in the Cognito User Pool:

# Get User Pool ID from stack outputs
USER_POOL_ID=$(aws cloudformation describe-stacks \
  --stack-name sentinel-prod-api-auth \
  --query 'Stacks[0].Outputs[?OutputKey==`UserPoolId`].OutputValue' \
  --output text)

# Create admin user
aws cognito-idp admin-create-user \
  --user-pool-id $USER_POOL_ID \
  --username admin \
  --user-attributes Name=email,Value=admin@example.com \
  --temporary-password TempPass123! \
  --message-action SUPPRESS

3. SES Email Verification

If using email notifications, verify your sender email in SES:

aws ses verify-email-identity --email-address noreply@yourdomain.com

4. Amplify Repository Connection

Connect your Amplify app to a Git repository:

  1. Go to the AWS Amplify console
  2. Find your app (sentinel-prod-app)
  3. Connect to your Git repository
  4. Configure build settings

5. Configure RSS Feeds

Update the config/feeds.yaml file with your RSS feed sources:

feeds:
  - name: "Krebs on Security"
    url: "https://krebsonsecurity.com/feed/"
    category: "security_news"
    priority: "high"
  - name: "Threatpost"
    url: "https://threatpost.com/feed/"
    category: "threat_intelligence"
    priority: "medium"

6. Update Keywords

Modify config/keywords.yaml to define relevance keywords:

high_priority:
  - "zero-day"
  - "ransomware"
  - "data breach"
  - "vulnerability"

medium_priority:
  - "malware"
  - "phishing"
  - "security update"

low_priority:
  - "security awareness"
  - "best practices"

7. OpenSearch Index Setup

If using AI features, you may need to create indices in OpenSearch:

# Get OpenSearch endpoint from stack outputs
OPENSEARCH_ENDPOINT=$(aws cloudformation describe-stacks \
  --stack-name sentinel-prod-ai \
  --query 'Stacks[0].Outputs[?OutputKey==`OpenSearchCollectionEndpoint`].OutputValue' \
  --output text)

# Create vector index (example)
curl -X PUT "$OPENSEARCH_ENDPOINT/sentinel-vector-index" \
  -H "Content-Type: application/json" \
  -d '{
    "mappings": {
      "properties": {
        "vector": {"type": "knn_vector", "dimension": 1536},
        "text": {"type": "text"},
        "metadata": {"type": "object"}
      }
    }
  }'

Testing the Deployment

1. Test API Endpoints

# Get API Gateway URL from stack outputs
API_URL=$(aws cloudformation describe-stacks \
  --stack-name sentinel-prod-api-auth \
  --query 'Stacks[0].Outputs[?OutputKey==`ApiGatewayUrl`].OutputValue' \
  --output text)

# Test analyst assistant endpoint (will return placeholder response)
curl -X POST "$API_URL/analyst-assistant" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are the latest security threats?"}'

2. Test Step Functions

# Get State Machine ARN
STATE_MACHINE_ARN=$(aws cloudformation describe-stacks \
  --stack-name sentinel-prod-backend \
  --query 'Stacks[0].Outputs[?OutputKey==`IngestionStateMachineArn`].OutputValue' \
  --output text)

# Start execution
aws stepfunctions start-execution \
  --state-machine-arn $STATE_MACHINE_ARN \
  --name test-execution-$(date +%s) \
  --input '{"feedConfigs": [], "batchSize": 10}'

3. Monitor Logs

# View Lambda logs
aws logs describe-log-groups --log-group-name-prefix "/aws/lambda/sentinel-prod"

# View Step Functions logs
aws logs describe-log-groups --log-group-name-prefix "/aws/stepfunctions/sentinel-prod"

Stack Management

Updating Stacks

To update individual stacks:

# Update a specific stack
aws cloudformation update-stack \
  --stack-name sentinel-prod-backend \
  --template-body file://03-backend-services-stack.yaml \
  --parameters file://parameters-prod.json \
  --capabilities CAPABILITY_NAMED_IAM \
  --region us-east-1

Stack Dependencies

Remember the dependency order when updating:

  1. Core Stack (no dependencies)
  2. Storage Stack (depends on Core)
  3. Backend Services Stack (depends on Core, Storage)
  4. AI/Bedrock Stack (depends on Core, Storage)
  5. API & Auth Stack (depends on Backend Services)

Monitoring and Maintenance

CloudWatch Dashboard

Access the pre-configured dashboard:

  1. Go to CloudWatch console
  2. Navigate to Dashboards
  3. Open "sentinel-prod-dashboard"

Key Metrics to Monitor

  • Lambda Function Errors: Monitor error rates and duration
  • DynamoDB Throttling: Watch for read/write capacity issues
  • Step Functions Failures: Track workflow execution success
  • API Gateway 4xx/5xx Errors: Monitor API health
  • S3 Storage Costs: Track storage growth
  • Bedrock API Calls: Monitor LLM usage and costs

Cost Optimization

  1. Review DynamoDB Usage: Consider switching to provisioned capacity for predictable workloads
  2. S3 Lifecycle Policies: Ensure old content transitions to cheaper storage classes
  3. Lambda Memory Optimization: Right-size memory allocation based on usage patterns
  4. Bedrock Usage: Monitor and optimize LLM API calls

Troubleshooting

Common Issues

  1. Stack Creation Fails

    • Check IAM permissions
    • Verify Bedrock access in your region
    • Ensure unique S3 bucket names
    • Check cross-stack references
  2. Lambda Functions Timeout

    • Increase timeout values in parameters
    • Check for network connectivity issues
    • Review function logs for bottlenecks
  3. Cross-Stack Reference Errors

    • Ensure stacks are deployed in correct order
    • Check that exported values exist
    • Verify stack names match expected patterns
  4. Bedrock Access Denied

    • Ensure Bedrock is enabled in your AWS account
    • Check model access permissions
    • Verify region availability
  5. OpenSearch Collection Creation Fails

    • Check service quotas
    • Verify encryption policy configuration
    • Ensure proper IAM permissions

Getting Help

  1. Check CloudFormation events for detailed error messages
  2. Review CloudWatch logs for runtime issues
  3. Consult AWS documentation for service-specific troubleshooting
  4. Use AWS Support for complex issues

Cleanup

To remove all infrastructure:

cd cloudformation
./delete-stacks.sh

The script will:

  1. Confirm deletion (type 'DELETE' to proceed)
  2. Empty all S3 buckets
  3. Delete OpenSearch collections
  4. Delete stacks in reverse dependency order
  5. Provide cleanup verification steps

Warning: This will delete all data and cannot be undone. Make sure to backup any important data before cleanup.

Force Deletion (Automated)

For automated cleanup (use with caution):

./delete-stacks.sh --force

Security Considerations

  1. Encryption: All data is encrypted at rest using KMS
  2. Network Security: Resources are deployed with proper security groups
  3. IAM Least Privilege: Roles have minimal required permissions
  4. API Security: API Gateway uses Cognito authentication
  5. Cross-Stack References: Secure resource sharing between stacks
  6. Secrets Management: Use AWS Secrets Manager for sensitive configuration

Scaling Considerations

  1. DynamoDB: Auto-scaling enabled for read/write capacity
  2. Lambda: Concurrent execution limits can be adjusted
  3. Step Functions: Parallel processing limits configurable
  4. API Gateway: Built-in scaling with throttling controls
  5. OpenSearch: Serverless scaling based on usage
  6. Modular Stacks: Individual components can be scaled independently

Backup and Disaster Recovery

  1. DynamoDB: Point-in-time recovery enabled
  2. S3: Versioning and cross-region replication available
  3. Lambda: Code stored in S3 for recovery
  4. Configuration: Infrastructure as Code enables quick recreation
  5. Cross-Stack Exports: Enable easy disaster recovery across stacks

Development Workflow

Lambda Development

  1. Implement functions in src/lambda/<function-name>/
  2. Add dependencies to requirements.txt in each function directory
  3. Test locally using AWS SAM or similar tools
  4. Re-run deployment script to update functions

Stack Updates

  1. Modify CloudFormation templates
  2. Update parameters if needed
  3. Deploy individual stacks or use full deployment script
  4. Monitor CloudFormation events for issues

CI/CD Integration

Consider integrating with:

  • AWS CodePipeline for automated deployments
  • GitHub Actions for CI/CD workflows
  • AWS SAM for Lambda function development and testing

This completes the deployment guide for the modular Sentinel Cybersecurity Triage Platform.