Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insight-Agent — AWS Deployment

Project Overview

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

  1. Set up an AWS account and create an IAM user with permissions for ECR and App Runner.

  2. Clone the repo locally.

  3. Configure your AWS credentials and any app environment variables (keep secrets out of the repo).

  4. Run Terraform to create all necessary AWS resources.

  5. Either build and push the Docker image yourself or let GitHub Actions handle it.

  6. Once deployed, use the API endpoint from App Runner to interact with the service.

  7. There is an instruction below on how to check and test the API

Features

  • 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.


Tech Stack

Component Technology
Language Python 3.12
Framework Flask
Containerization Docker
Deployment AWS App Runner
Container Registry Amazon ECR
IaC Terraform
CI/CD GitHub Actions

Test application

Screenshot from 2025-08-09 11-26-39

Deployment Workflow

1️ Build & Tag Docker Image

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.0

Screenshot from 2025-08-09 10-09-32


2 Push to Amazon ECR

aws 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.0

Screenshot from 2025-08-08 17-42-28


3️ Provision AWS Infrastructure (Terraform)

terraform init
terraform apply -auto-approve

Terraform provisions:

  • Amazon ECR repository
  • AWS App Runner service
  • IAM roles & permissions

Terraform apply

Screenshot from 2025-08-09 13-08-32


creating policies

Screenshot from 2025-08-09 11-53-13


attach policy

Screenshot from 2025-08-09 11-53-30


4️ Deploy to App Runner

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

WhatsApp Image 2025-08-09 at 15 50 20


5 Test the API

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:

Screenshot from 2025-08-09 13-19-05


CI/CD with GitHub Actions

Every push to main triggers:

  1. Docker image build
  2. Push to ECR
  3. App Runner deployment update via Terraform

GitHub Actions workflow run screenshot:

Screenshot from 2025-08-09 15-07-08


Achievements

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages