Deploying A Fastapi App To Aws Eks With Docker Ecr And Github Actions
In this guide, I’ll show you how to build a secure AWS EKS(Kubernetes) CI/CD pipeline for your FastAPI app complete with GitHub Actions, Docker, and OpenID Connect (OIDC) all while following AWS security best... We won’t obsess over every detail of FastAPI or Docker, but we’ll cover enough to get your application running on EKS with confidence. Note: The primary focus of this blog is on CI/CD processes and AWS configuration, so we won’t dive too deeply into FastAPI or Docker fundamentals. Managing Kubernetes on AWS via EKS is a great approach, but configuring secure access for CI/CD can be tricky. With OIDC, GitHub Actions can assume roles in AWS without storing secret keys, so no static credentials, Let’s walk through setting up an EKS cluster, creating an ECR repo, and configuring GitHub Actions to... Create (or use) a repository that holds your FastAPI app and Kubernetes manifests:
Keep your code organized. The .yaml files will be applied to EKS to deploy the FastAPI service. These days I use Kamal to deploy my FastAPI (or Django) projects. Kamal is a simpler alternative to Kubernetes that you can use to deploy containerized apps to a VPS. Once you get the hang of it, it’ll only take you a few minutes to set up a CI/CD pipeline that automatically deploys your app to production with each push to the main branch. In this tutorial, I’ll walk you through the process of deploying a FastAPI app with Kamal, AWS ECR, and Github Actions.
You can find the code for this tutorial in this repository. To make the most of this tutorial, you should: In this guide, I’ll show you how to build a secure AWS EKS(Kubernetes) CI/CD pipeline for your FastAPI app complete with GitHub Actions, Docker, and OpenID Connect (OIDC) all while following AWS security best... We won’t obsess over every detail of FastAPI or Docker, but we’ll cover enough to get your application running on EKS with confidence. Note: The primary focus of this blog is on CI/CD processes and AWS configuration, so we won’t dive too deeply into FastAPI or Docker fundamentals. Managing Kubernetes on AWS via EKS is a great approach, but configuring secure access for CI/CD can be tricky.
With OIDC, GitHub Actions can assume roles in AWS without storing secret keys, so no static credentials, Let’s walk through setting up an EKS cluster, creating an ECR repo, and configuring GitHub Actions to... Create (or use) a repository that holds your FastAPI app and Kubernetes manifests: Keep your code organized. The .yaml files will be applied to EKS to deploy the FastAPI service. This lab shows you how to deploy the microservices of the python-fastapi-demo-docker project onto your Amazon EKS cluster—either your AWS Fargate or managed node groups-based cluster. To gain a deeper understanding of the Kubernetes resources in these manifests, refer to Deploying FastAPI and PostgreSQL Kubernetes resources to Amazon EKS.
Navigate to the root directory of the python-fastapi-demo-docker project where your environment variables are sourced: Run the following command from the python-fastapi-demo-docker project directory to create the ConfigMap: The expected output should look like this: To confirm that your Kubernetes Configmap has been successfully created, you can use the kubectl get configmap command. This command lists all ConfigMaps that exist in the specified namespace: This project implements a REST API using FastAPI to expose a Machine Learning model.
It is designed to be packaged with Docker, pushed to AWS ECR, and deployed to Kubernetes (EKS) using an automated GitHub Actions CI/CD workflow. In my latest efforts to learn more about DevOps tools and practices, I set out to deploy the Docker image for my FastAPI app API to AWS. You can read about the process of building the image in my last post. This post is part of a series where I create a basic CRUD app and improve upon the development and deployment of the app using DevOps tools and techniques. Initially, I was overwhelmed by the many ways to run containers on AWS. I mistakenly decided to try Lambda - partially to use the most “serverless” method I could, but mostly to be as cheap as possible.
Many painful hours of not getting it to work later, and I decided to try out ECS instead. Either way, first I needed to push my Docker image to AWS ECR. I was able to do this part using the AWS CLI. First I created a new ECR repository: Next, AWS gave instructions on how to authenticate the local Docker utility to my AWS: Tired of manually deploying your applications?
What if you could push code to GitHub, run tests automatically, and deploy updates to your live server—without lifting a finger? That’s exactly what I did with my FastAPI project using CI/CD. I’ll walk you through how I set up a Continuous Integration (CI) pipeline to automatically test my code... Continuous Deployment (CD) pipeline to push updates to an AWS EC2 instance. This project demonstrates microservices communication using FastAPI. It consists of three services that are built into Docker images and deployed to AWS EKS automatically.
The infrastructure, including the EKS cluster and all required components, is provisioned using Terraform. Before deploying, update the following files: After making these changes, push the modified code to your repository. GitHub Actions will automatically: Note: Homebrew is required for macOS. Modify the script if you are using Windows.
This will configure your local environment and AWS credentials.
People Also Search
- Deploying a FastAPI App to AWS EKS with Docker, ECR, and GitHub Actions
- Build a Secure CI/CD Pipeline for Amazon EKS Using GitHub Actions and ...
- Deploying a FastAPI app with Kamal, AWS ECR, and Github Actions
- David Hyppolite's Blog
- How to Scale from Zero to Unicorn — FastAPI Containerization and ...
- Deploying FastAPI and PostgreSQL Microservices to EKS
- ML API - FastAPI Deployment on AWS - GitHub
- Deploying a FastAPI Container to AWS ECS - rickt.io
- Deploying a FastAPI App with CI/CD: GitHub Actions, Docker, Nginx & AWS ...
- GitHub - andyg2025/fastApi_demo_EKS
In This Guide, I’ll Show You How To Build A
In this guide, I’ll show you how to build a secure AWS EKS(Kubernetes) CI/CD pipeline for your FastAPI app complete with GitHub Actions, Docker, and OpenID Connect (OIDC) all while following AWS security best... We won’t obsess over every detail of FastAPI or Docker, but we’ll cover enough to get your application running on EKS with confidence. Note: The primary focus of this blog is on CI/CD proc...
Keep Your Code Organized. The .yaml Files Will Be Applied
Keep your code organized. The .yaml files will be applied to EKS to deploy the FastAPI service. These days I use Kamal to deploy my FastAPI (or Django) projects. Kamal is a simpler alternative to Kubernetes that you can use to deploy containerized apps to a VPS. Once you get the hang of it, it’ll only take you a few minutes to set up a CI/CD pipeline that automatically deploys your app to producti...
You Can Find The Code For This Tutorial In This
You can find the code for this tutorial in this repository. To make the most of this tutorial, you should: In this guide, I’ll show you how to build a secure AWS EKS(Kubernetes) CI/CD pipeline for your FastAPI app complete with GitHub Actions, Docker, and OpenID Connect (OIDC) all while following AWS security best... We won’t obsess over every detail of FastAPI or Docker, but we’ll cover enough to...
With OIDC, GitHub Actions Can Assume Roles In AWS Without
With OIDC, GitHub Actions can assume roles in AWS without storing secret keys, so no static credentials, Let’s walk through setting up an EKS cluster, creating an ECR repo, and configuring GitHub Actions to... Create (or use) a repository that holds your FastAPI app and Kubernetes manifests: Keep your code organized. The .yaml files will be applied to EKS to deploy the FastAPI service. This lab sh...
Navigate To The Root Directory Of The Python-fastapi-demo-docker Project Where
Navigate to the root directory of the python-fastapi-demo-docker project where your environment variables are sourced: Run the following command from the python-fastapi-demo-docker project directory to create the ConfigMap: The expected output should look like this: To confirm that your Kubernetes Configmap has been successfully created, you can use the kubectl get configmap command. This command ...