Deployment Guide
Deployment Options
Section titled “Deployment Options”Option 1: ECS Fargate (Recommended)
Section titled “Option 1: ECS Fargate (Recommended)”The bot is designed to run on AWS ECS Fargate alongside the Chukfi CMS backend.
Step 1: Build and Push to ECR
Section titled “Step 1: Build and Push to ECR”# Authenticate with ECRaws ecr get-login-password --region us-east-1 | \ docker login --username AWS --password-stdin \ <account-id>.dkr.ecr.us-east-1.amazonaws.com
# Create repositoryaws ecr create-repository --repository-name chukfi-teams-bot
# Build and pushdocker build -t chukfi-teams-bot -f chukfi-teams-bot/Dockerfile .docker tag chukfi-teams-bot:latest \ <account-id>.dkr.ecr.us-east-1.amazonaws.com/chukfi-teams-bot:latestdocker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/chukfi-teams-bot:latestStep 2: Create ECS Task Definition
Section titled “Step 2: Create ECS Task Definition”{ "family": "chukfi-teams-bot", "taskRoleArn": "arn:aws:iam::<account-id>:role/chukfi-teams-bot-task-role", "executionRoleArn": "arn:aws:iam::<account-id>:role/ecsTaskExecutionRole", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "256", "memory": "512", "containerDefinitions": [ { "name": "chukfi-teams-bot", "image": "<account-id>.dkr.ecr.us-east-1.amazonaws.com/chukfi-teams-bot:latest", "portMappings": [{"containerPort": 8000, "protocol": "tcp"}], "environment": [ {"name": "AWS_REGION", "value": "us-east-1"}, {"name": "BEDROCK_MODEL_ID", "value": "anthropic.claude-3-5-haiku-20241022-v1:0"}, {"name": "DATABASE_URL", "value": "postgresql://..."}, {"name": "LOG_LEVEL", "value": "INFO"} ], "secrets": [ {"name": "TEAMS_WEBHOOK_SECRET", "valueFrom": "arn:aws:secretsmanager:us-east-1:<account-id>:secret:teams-webhook-secret"} ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/chukfi-teams-bot", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs" } } } ]}Step 3: Deploy Behind ALB
Section titled “Step 3: Deploy Behind ALB”- Create an Application Load Balancer in the same VPC
- Create a target group for port 8000 (health check path:
/health) - Create an HTTPS listener with an ACM certificate
- Register the ECS service with the target group
- Point
teams-bot.yourdomain.comat the ALB DNS name
Option 2: Cloud VM
Section titled “Option 2: Cloud VM”Any Linux VM works. The bot is lightweight:
# Install dependenciesapt update && apt install -y python3 python3-pippip install -r requirements.txt
# Run as a systemd servicecat > /etc/systemd/system/chukfi-teams-bot.service << 'EOF'[Unit]Description=Chukfi Teams BotAfter=network.target
[Service]Type=simpleUser=chukfiWorkingDirectory=/opt/chukfi-teams-botEnvironmentFile=/opt/chukfi-teams-bot/.envExecStart=/usr/local/bin/uvicorn main:app --host 0.0.0.0 --port 8000Restart=alwaysRestartSec=5
[Install]WantedBy=multi-user.targetEOF
systemctl enable --now chukfi-teams-botOption 3: Docker Compose (Local/Staging)
Section titled “Option 3: Docker Compose (Local/Staging)”version: "3.8"services: teams-bot: build: context: . dockerfile: Dockerfile ports: - "8000:8000" env_file: .env restart: unless-stoppedGitHub Actions
Section titled “GitHub Actions”name: Deploy Teams Bot
on: push: branches: [main] paths: - 'chukfi-teams-bot/**'
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1
- name: Build and push to ECR run: | docker build -t chukfi-teams-bot -f chukfi-teams-bot/Dockerfile . docker tag chukfi-teams-bot:latest $ECR_REPO:latest docker push $ECR_REPO:latest
- name: Deploy to ECS run: | aws ecs update-service \ --cluster chukfi \ --service chukfi-teams-bot \ --force-new-deploymentHealth Checks
Section titled “Health Checks”The bot exposes a health check endpoint:
curl https://your-server.com/health# {"status": "ok", "version": "0.2.0"}Configure your load balancer or orchestrator to use GET /health with a 30-second interval.
Monitoring
Section titled “Monitoring”CloudWatch Logs
Section titled “CloudWatch Logs”The bot logs structured JSON to stdout. Key things to monitor:
Message from %s (Tenant: %s)— Incoming requestsTool call: %s(%s)— Every tool executionCLI failed (exit=%d)— CLI errorsBedrock API error— Bedrock connectivity issuesUnauthorized access attempt— Security events
Alarms
Section titled “Alarms”Set up CloudWatch alarms for:
- 5xx errors on the ALB → Bedrock or CLI failure
- 401 responses → Possible HMAC misconfiguration or intrusion attempt
- Zero requests in 1 hour → Bot may be down