{"id":23780907,"url":"https://github.com/ajithvcoder/emlo4-session-11-ajithvcoder","last_synced_at":"2026-04-18T01:32:44.714Z","repository":{"id":267015071,"uuid":"897819704","full_name":"ajithvcoder/emlo4-session-11-ajithvcoder","owner":"ajithvcoder","description":"Use CDK to create lambda resouces using github actions and deploy - The School of AI EMLO-V4 course assignment https://theschoolof.ai/#programs","archived":false,"fork":false,"pushed_at":"2024-12-08T04:03:32.000Z","size":3259,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-11T01:16:41.987Z","etag":null,"topics":["aws-cdk","aws-lambda","docker","github-actions","workflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajithvcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-03T09:47:44.000Z","updated_at":"2025-01-16T01:25:48.000Z","dependencies_parsed_at":"2024-12-07T18:30:42.570Z","dependency_job_id":null,"html_url":"https://github.com/ajithvcoder/emlo4-session-11-ajithvcoder","commit_stats":null,"previous_names":["ajithvcoder/emlo4-session-11-ajithvcoder"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ajithvcoder/emlo4-session-11-ajithvcoder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Femlo4-session-11-ajithvcoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Femlo4-session-11-ajithvcoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Femlo4-session-11-ajithvcoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Femlo4-session-11-ajithvcoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajithvcoder","download_url":"https://codeload.github.com/ajithvcoder/emlo4-session-11-ajithvcoder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2Femlo4-session-11-ajithvcoder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31953515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"ssl_error","status_checked_at":"2026-04-18T00:39:20.671Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-cdk","aws-lambda","docker","github-actions","workflow"],"created_at":"2025-01-01T11:18:17.214Z","updated_at":"2026-04-18T01:32:44.508Z","avatar_url":"https://github.com/ajithvcoder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## EMLOV4-Session-11 Assignment -Deployment w/ Serverless\n\n### Contents\n\n- [Requirements](#requirements)\n- [Development Method](#development-method)\n    - [AWS CDK Integration](#aws-cdk-integration)\n    - [Github Actions Pipeline](#github-actions-pipeline)\n- [Learnings](#learnings)\n- [Results Screenshots](#results-screenshots)\n\n### Requirements\n\n- Create a CI/CD Pipeline to deploy/update the model to AWS Lambda\n- Submit the deployed function URL\n\n### Development Method\n\n**Installations**\n\n```\n    # aws cli\n    curl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\n    unzip awscliv2.zip\n    sudo ./aws/install\n\n    # python requirements\n    pip install -r requirements-dev.txt\n    pip install -r requirements.txt\n\n    # aws-cdk cli\n    npm install -g aws-cdk\n```\n\n**Build Command**\n\n- `python3 export_onnx.py`\n\n**Deploy locally**\n\n- `uvicorn --host 0.0.0.0 --port 8000 app:app`\n\n**Test locally**\n\n- `pytest test.py`\n\n**Docker test**\n\n- `docker build -t fastapi-classifier .`\n\n- `docker run -p 8000:8000 fastapi-classifier`\n\n**CDK Usage**\n\n- `cdk bootstrap`\n\n- `cdk deploy --require-approval=never`\n\n- `cdk destroy`\n\n**Debug Command**\n\nIn case if you have deleted aws lambda function manually in UI, use below to clean completely else it would throw error while deploying agan\n\n`aws cloudformation delete-stack --stack-name CatDogClassifierFastAPIStack`\n\n### AWS CDK Integration\n\n- In cdk.py file `CatDogClassifierFastAPIStack` class is used to fetch a `Dockerfile` and create a container like service with aws lambda service.\n- While developing in local make sure that you have set all the environment variables\n    - `aws configure`  -\u003e `AWS_ACCESS_KEY`, `AWS_SECRET_KEY`, `AWS_REGION`\n    - `CDK_DEFAULT_ACCOUNT`, `CDK_DEFAULT_REGION`\n- After running `cdk bootstrap` command is used to set up the necessary AWS resources that AWS CDK needs to deploy your infrastructure. It prepares your AWS environment for the first time deployment or when you need to deploy infrastructure that requires certain resources like storing docker image, I am roles, CloudFormation.\n- `cdk deploy` - Deploys your infrastructure to AWS as defined by your CDK stack.\n- `cdk destroy` - Destroy all resources created about without any traces left.\n\n### Github Actions Pipeline\n\n- Configure the following env variables in github secrets\n\n    - `AWS_ACCESS_KEY`, `AWS_SECRET_KEY`, `AWS_REGION`\n    - `CDK_DEFAULT_ACCOUNT`, `CDK_DEFAULT_REGION`\n\n- Use `actions/checkout@v4`, `actions/setup-python@v5`, `actions/setup-node@v4` to checkout the code, install python env and node.\n\n- Export the onnx model from torch script and use cdk to deploy the fast api service to serveless lambda service\n\n### Learnings\n\n- Use AWS CDK and create AWS cloud resources programatically.\n\n### Results Screenshots\n\n**Deployed URL**\n\n![](./assets/snap_output_session-11.png)\n\n\n![](./assets/snap_output_ui_session-11.png)\n\n\n**CI CD run**\n\n- Run [here](https://github.com/ajithvcoder/emlo4-session-11-ajithvcoder/actions/runs/12218377937/job/34083798481)\n\n\n![](./assets/snap_run_cicd_session-11.png)\n\n\n\n### Group Members\n\n1. Ajith Kumar V (myself)\n2. Pravin Sagar\n3. Pratyush\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Femlo4-session-11-ajithvcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajithvcoder%2Femlo4-session-11-ajithvcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Femlo4-session-11-ajithvcoder/lists"}