Sentinel
Video-surveillance compliance platform.
My role: I designed and built the AWS infrastructure, CI/CD and deployments. The application code was written by the dev teams.
Context
Sentinel is a video-surveillance compliance platform. It ingests live camera streams and runs computer-vision checks on them — people and object detection, face detection, protective-equipment (PPE) compliance and content moderation — so that sites can be monitored against safety and compliance rules.
The product is a web application with a dashboard for operators plus a separate service that does the frame-by-frame vision work. My job was the AWS side: the network, the containers, the database, the delivery pipeline and the security and cost controls around it.
The problem
The application needed a home on AWS that could run two very different workloads side by side — a user-facing Rails and React app, and an internal Python vision service — while keeping each one locked down to exactly what it needs.
A few things made the infrastructure interesting. The vision service calls a managed computer-vision API once per video frame, so an unbounded stream could quietly run up a large bill. The database had to stay completely private. Deploys had to happen from CI without any long-lived AWS keys sitting in a pipeline. And the vision service must never be reachable from the internet — only the API should be able to talk to it.
Architecture
What I built
Network
- A VPC (
10.0.0.0/16) inus-east-1with four subnets across two availability zones: two public, two private. - Public route table to the Internet Gateway; the ECS private subnet (private-1) routes to a single NAT Gateway, plus a local route and an S3 gateway endpoint.
- The RDS private subnet (private-2) has no internet route at all — only the local route and the S3 gateway endpoint.
- Cost-aware single-AZ compute: the ECS tasks and one NAT Gateway (with an Elastic IP) live in AZ-a. The second private subnet in AZ-b exists only to satisfy the RDS subnet-group two-AZ requirement.
- The internet-facing ALB terminates TLS with an ACM certificate and redirects HTTP to HTTPS, so traffic is encrypted in transit.
Compute
- An ECS Fargate cluster (
sentinel-cluster) running two services from shared task-execution and task roles. sentinel-api: Rails 7.2 + React 18 at 0.5 vCPU / 1 GB, behind an internet-facing ALB with an IP target group.sentinel-ai-service: Python 3.12 + FastAPI, internal only — no ALB and no target group — reached by the API over ECS Service Connect.- Runtime configuration passed through the task definitions (
RAILS_ENV,DATABASE_URL,AI_SERVICE_URL).
Data
- RDS PostgreSQL on
db.t3.micro, Single-AZ, in the private subnets. - Reachable only from the ECS service on port 5432 — never from the internet.
- A two-AZ subnet group so the database can move to Multi-AZ later without re-wiring the network.
CI/CD
- Bitbucket Pipelines builds both images and pushes them to two ECR repositories.
- Deploys run
RegisterTaskDefinitionthenUpdateServiceagainst the two ECS services. - Authentication uses a Bitbucket OIDC token exchanged for an IAM role — no long-lived AWS keys stored in the pipeline.
Security & cost
- A least-privilege security-group chain: ALB SG (80/443 from the internet) → ECS SG (container ports from the ALB SG only, plus a self-referencing rule so the API can reach the AI service) → RDS SG (5432 from the ECS SG only).
- A scoped deploy role:
ecr:GetAuthorizationToken, push to the two repos only,ecs:UpdateService/DescribeServiceson the specific services,ecs:RegisterTaskDefinition, andiam:PassRolelimited to the two task roles with a condition ofiam:PassedToService = ecs-tasks.amazonaws.com. - Rekognition access via a dedicated policy on the task role (
DetectLabels,DetectFaces,DetectProtectiveEquipment,DetectModerationLabels). - A cost guardrail: an AWS Budget of $10/month scoped to Rekognition, an alert at 80%, and a Budget Action that automatically attaches a deny policy to stop Rekognition calls if the budget is breached — so runaway per-frame API costs can't happen.
- Amazon SES for notification email, with
ses:SendEmail/ses:SendRawEmailon the task role.
Deploy flow
- git push to Bitbucket triggers the pipeline.
- The pipeline exchanges an OIDC token for an IAM role — no stored AWS keys — and signs in to ECR.
- It builds both images (the Rails + React API and the FastAPI AI service) and pushes them to the two ECR repositories.
- RegisterTaskDefinition creates a new revision for each service with the updated image.
- UpdateService rolls the new revision onto
sentinel-apiandsentinel-ai-serviceon Fargate. - The ALB health-checks the new API tasks before shifting traffic, so a bad revision replaces itself with minimal-downtime.
Security decisions
A one-way security-group chain
Each tier only accepts traffic from the tier in front of it: the internet reaches the ALB, the ALB reaches the ECS tasks, and only the ECS tasks reach the database. Nothing can skip a step.
TLS terminates at the ALB
The internet-facing ALB has an HTTPS listener backed by an ACM certificate, and the HTTP listener redirects to HTTPS — so traffic between clients and the load balancer is always encrypted in transit.
The AI service is internal, by design
It has no load balancer and no target group. The API reaches it over ECS Service Connect through a self-referencing security-group rule, so the vision service is never exposed to the internet.
No long-lived keys in CI
Bitbucket authenticates with a short-lived OIDC token that is exchanged for an IAM role. There is nothing to leak from the pipeline, and the role itself is scoped to exactly the ECR and ECS actions a deploy needs.
PassRole is pinned to ECS
The deploy role can only pass the two task roles, and only to ecs-tasks.amazonaws.com. It cannot hand those roles to any other service.
The database has no way out
The RDS subnet has no internet route — only the local route and an S3 gateway endpoint — so the data tier cannot reach, or be reached from, the public internet.
A hard ceiling on vision spend
Because the AI service calls Rekognition once per frame, cost is the real risk. An AWS Budget scoped to Rekognition alerts at 80% and, if breached, a Budget Action attaches a deny policy that stops further Rekognition calls — the bill is capped automatically rather than discovered later.
Challenges & fixes
The AI image was too large
The vision service needs ffmpeg, and the distro ffmpeg packages pulled in a lot of weight. I switched to a single static ffmpeg binary instead, which shrank the image.
Building OpenCV from source was slow
Compiling opencv-python-headless from source would have kept builds fast only at the cost of a larger image, so I deferred it to keep both the build time and the image small for now.
RTSP ingest was blocked at the client site
The cameras stream over RTSP, and that path was blocked by a network limitation at the client site — not on AWS. The infrastructure was ready; the fix depended on the site's own network team.
What's next
- Tighten the SES policy from
Resource: "*"to the specific verified-identity ARNs. - Move SES out of the sandbox for production sending.
- Go Multi-AZ for compute and NAT, and for RDS, once traffic justifies the second-NAT cost.