Insight-Agent is a Python AI microservice that accepts JSON text input and returns key statistics such as word count and character count. It’s containerized, stored in Amazon ECR, and deployed to AWS App Runner with Terraform for Infrastructure-as-Code. GitHub Actions handles CI/CD for automated deployments.
Design Decisions
I used AWS App Runner because it makes deploying and scaling container apps super easy without managing servers.
For security, I rely on AWS IAM roles and keep secrets out of the code by using environment variables and AWS’s secret management tools. All data goes through secure HTTPS.
The CI/CD pipeline runs on GitHub Actions — it builds the Docker image, pushes it to AWS ECR, and updates the App Runner service automatically whenever I push new code.
Setup & Deployment
-
Set up an AWS account and create an IAM user with permissions for ECR and App Runner.
-
Clone the repo locally.
-
Configure your AWS credentials and any app environment variables (keep secrets out of the repo).
-
Run Terraform to create all necessary AWS resources.
-
Either build and push the Docker image yourself or let GitHub Actions handle it.
-
Once deployed, use the API endpoint from App Runner to interact with the service.
-
There is an instruction below on how to check and test the API
-
Accepts JSON payload:
{"text": "I love cloud engineering!"} -
Returns:
{ "original_text": "I love cloud engineering!", "word_count": 4, "character_count": 27 } -
Runs in a lightweight Python 3.12 debian-based Docker container.
-
Fully automated provisioning with Terraform.
-
Deployed serverlessly via AWS App Runner.
-
Private ECR repository with authentication handled by AWS IAM roles.
| Component | Technology |
|---|---|
| Language | Python 3.12 |
| Framework | Flask |
| Containerization | Docker |
| Deployment | AWS App Runner |
| Container Registry | Amazon ECR |
| IaC | Terraform |
| CI/CD | GitHub Actions |
docker build --no-cache -t insight-agent:v1.0 .
docker tag insight-agent:v1.0 867251709990.dkr.ecr.us-east-1.amazonaws.com/insight-agent:v1.0aws ecr get-login-password --region us-east-1 \
| docker login --username AWS --password-stdin 867251709990.dkr.ecr.us-east-1.amazonaws.com
docker push 867251709990.dkr.ecr.us-east-1.amazonaws.com/insight-agent:v1.0terraform init
terraform apply -auto-approveTerraform provisions:
- Amazon ECR repository
- AWS App Runner service
- IAM roles & permissions
Terraform apply
creating policies
attach policy
Terraform automatically links ECR to App Runner and starts deployment. Once deployed, retrieve your service URL from the AWS console:
https://ir2m2ei8vk.us-east-1.awsapprunner.com/analyze
curl -X POST "https://ir2m2ei8vk.us-east-1.awsapprunner.com/analyze" \
-H "Content-Type: application/json" \
-d '{"text": "I love cloud engineering!"}'Response:
{
"original_text": "I love cloud engineering!",
"word_count": 4,
"character_count": 27
}terminal output screenshot here:
Every push to main triggers:
- Docker image build
- Push to ECR
- App Runner deployment update via Terraform
GitHub Actions workflow run screenshot:
- Fully containerized Python app using minimal Python 3.12 Alpine image.
- Automated provisioning with Terraform (repeatable deployments).
- Private ECR repo for secure container storage.
- Serverless deployment with AWS App Runner.
- Terminal-based API testing via
curl. - CI/CD automation with GitHub Actions.