How tyaba/aws-mlops-handson works
Main Subsystems
• Training Pipeline (Batch ML)
• Prediction Server (Online Inference)
• Infrastructure-as-Code / CI/CD
Enumerate Core AWS Components (from infra/…)
• VPC & Networking (infra/modules/network)
• IAM Roles & Policies (infra/modules/iam)
• S3 Bucket for Data & Models (infra/modules/s3)
• ECR Repositories for Container Images (infra/modules/ecr)
• ECS Cluster + Task Definitions
– ml_pipeline container (infra/modules/ecs/container_definitions/ml_pipeline.json)
– predict_api container (…/predict_api.json)
• ALB (infra/modules/alb) with Listener → ECS service
• Step Functions orchestration (infra/modules/stepfunctions)
• Terraform “root” (infra/.all) invoking all modules
• GitHub Actions workflow (/.github/workflows/test-mlops-handson.yml)
Sketching the Training Pipeline Flow
a. Trigger
– Manual CLI (“make run-ml”) or automated Step Functions StartExecution
b. Step Functions State Machine
– Calls an ECS “RunTask” for ml_pipeline container
c. ECS Task (ml/main.py)
– ml/dataset loads raw data (data/train_data.zip or S3)
– ml/preprocessor preprocesses features
– ml/model trains classifiers (sgd_classifier_ctr_model, optuna)
– ml/logger records metrics
– Upload trained model/artifacts to S3
d. (Optional) Downstream: Model registered or results pulled
Sketching the Prediction Server Flow
a. Client HTTP Request → ALB
b. ALB Listener & Target Group → ECS Service (predict_api)
c. Predictor Container (predictor/app.py)
– On startup, fetch model from S3 via ml/aws/controller.py
– serve REST endpoints (predictor/routers.py, predictor/request.py)
d. Returns CTR prediction JSON
Infrastructure Provisioning / CI
• Terraform code (infra/.all/main.tf) provisions all AWS resources
• Dockerfiles + Makefile build two images (ML pipeline & predictor)
• Images pushed to ECR (infra/modules/ecr)
• Task definitions updated in ECS (infra/modules/ecs)
• GitHub Actions can run tests, then apply Terraform, build & push images
Architectural Patterns & Design Principles
• Separation of concerns:
– ML training (batch) vs. inference (online)
– IaC (Terraform) separated into reusable modules (network, iam, s3, etc.)
• Event-driven orchestration with AWS Step Functions
• Containerized workloads on ECS Fargate
• REST API behind ALB for horizontal scaling
• Strong Dev/Ops practices: Makefile, Poetry, pytest, GitHub Actions
Final Checklist
• Every AWS resource labeled (e.g., “ECS Cluster: mlops-cluster”)
• Containers annotated with image names (e.g., “ml-pipeline:latest”, “predict-api:latest”)
– Code build → ECR push
– Terraform apply → AWS resource creation
– Step Functions → ECS Task Run
– ECS → S3 (read/write)
– Client → ALB → ECS
– Compute vs. Storage vs. Orchestration vs. IaC
• Optionally, annotate file paths next to each major component (e.g., “infra/modules/ecs/…/predict_api.json”)