{"id":25666445,"url":"https://github.com/rafavermar/terraform_eks_fastapi","last_synced_at":"2026-04-18T01:01:47.946Z","repository":{"id":239089845,"uuid":"798504185","full_name":"Rafavermar/Terraform_EKS_Fastapi","owner":"Rafavermar","description":"This repository contains all necessary configurations and guidelines for deploying a bookstore application built with FastAPI on AWS Elastic Kubernetes Service (EKS) using Terraform. This project demonstrates setting up a robust Kubernetes cluster and deploying microservices that manage books and client data, utilizing an API Gateway for seamless s","archived":false,"fork":false,"pushed_at":"2024-06-14T10:35:23.000Z","size":5476,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T13:06:45.311Z","etag":null,"topics":["aws","eks","fastapi","helm","nginx","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rafavermar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-05-09T23:02:22.000Z","updated_at":"2025-05-06T17:08:37.000Z","dependencies_parsed_at":"2024-05-10T00:21:52.057Z","dependency_job_id":"703fba2d-fa22-4a31-b69d-c830feb628a0","html_url":"https://github.com/Rafavermar/Terraform_EKS_Fastapi","commit_stats":null,"previous_names":["rafavermar/terraform_eks_fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rafavermar/Terraform_EKS_Fastapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rafavermar%2FTerraform_EKS_Fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rafavermar%2FTerraform_EKS_Fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rafavermar%2FTerraform_EKS_Fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rafavermar%2FTerraform_EKS_Fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rafavermar","download_url":"https://codeload.github.com/Rafavermar/Terraform_EKS_Fastapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rafavermar%2FTerraform_EKS_Fastapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31952206,"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","eks","fastapi","helm","nginx","terraform"],"created_at":"2025-02-24T08:30:15.801Z","updated_at":"2026-04-18T01:01:47.930Z","avatar_url":"https://github.com/Rafavermar.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploying FastAPI Microservices on AWS Elastic Kubernetes Service (EKS) using Terraform\n\nThis repository contains all necessary configurations and guidelines for deploying a bookstore application built with FastAPI on AWS Elastic Kubernetes Service (EKS) using Terraform. This project demonstrates setting up a robust Kubernetes cluster and deploying microservices that manage books and client data, utilizing an API Gateway for seamless service interaction.\n![Project_architecture.png](Assets/Project_architecture.png)\n\n## Prerequisites\n\nBefore you start, make sure you have installed and configured the following tools:\n\n- [AWS CLI](https://aws.amazon.com/cli/) - Command-line tool for managing AWS resources.\n- [Visual Studio Code](https://code.visualstudio.com/download) or [PyCharm](https://www.jetbrains.com/pycharm/download/) with the Terraform extension.\n- [Terraform CLI](https://www.terraform.io/downloads.html) - Installed and added to your system's PATH.\n- [Kubectl](https://kubernetes.io/docs/tasks/tools/) - Kubernetes command-line tool, also added to your system's PATH.\n- An AWS account with an active subscription / Free tier.\n\n## Repository Structure\n\n- `TerraformScriptsEKS`: Contains Terraform scripts for provisioning the EKS cluster.\n- `FastAPIApps`: Contains the FastAPI applications along with Dockerfiles and `requirements.txt` for each microservice.\n- `assets`: This folder contains a complete list of commands used (`commands.txt`) and a PDF with step-by-step screenshots detailing the entire process.\n- `deployments`: Kubernetes YAML configurations for deploying the microservices.\n\n## Project Setup\n\n### Step 1: Terraform Setup for EKS\n\n1. **Environment Setup:**\n   - Install all required tools and ensure they are correctly configured in your system's PATH.\n\n2. **Terraform Initialization and Application:**\n   - Navigate to the `TerraformScriptsEKS` directory.\n   - Initialize Terraform:\n     ```bash\n     terraform init -upgrade\n     ```\n   - Create an execution plan:\n     ```bash\n     terraform plan -out main.tfplan\n     ```\n   - Apply the configuration to provision the EKS cluster:\n     ```bash\n     terraform apply main.tfplan\n     ```\n\n3. **Connect to the EKS Cluster:**\n   - Update kubeconfig to interact with your cluster:\n     ```bash\n     aws eks --region us-west-2 update-kubeconfig --name \u003ccluster-name\u003e\n     ```\n\n### Step 2: FastAPI Microservices Development\n\n1. **Build and Push Docker Images:**\n   - Navigate to each FastAPI application directory.\n   - Build and push the Docker images:\n     ```bash\n     docker build . -t \u003cyour-dockerhub-username\u003e/\u003capp-name\u003e:\u003ctag\u003e .\n     docker push \u003cyour-dockerhub-username\u003e/\u003capp-name\u003e:\u003ctag\u003e\n     ```\n\n2. **Deploy Microservices:**\n   - Apply the Kubernetes deployment and PVC configurations:\n     ```bash\n     kubectl apply -f books-data-pvc.yml\n     kubectl apply -f books-deployment.yml\n     kubectl apply -f clients-data-pvc.yml\n     kubectl apply -f clients-deployment.yml\n     ```\n\n### Step 3: AWS EFS Integration with Kubernetes\n\n1. **Install the AWS EFS CSI Driver:**\n   - Use Helm to install the AWS EFS CSI driver which enables Kubernetes to manage EFS file systems efficiently:\n     ```bash\n     helm repo add aws-efs-csi-driver https://kubernetes-sigs.github.io/aws-efs-csi-driver/\n     helm repo update\n     helm upgrade --install aws-efs-csi-driver --namespace kube-system aws-efs-csi-driver/aws-efs-csi-driver\n     ```\n\n### Step 4: ConfigMap Configuration\n\n1. **Setup ConfigMaps:**\n   - Create a directory for configuration files:\n     ```powershell\n     New-Item -ItemType Directory -Path .\\gateway-conf\n     ```\n   - Copy the configuration file into the new directory:\n     ```powershell\n     Copy-Item -Path .\\gateway\\app\\conf.d\\main.yml -Destination .\\gateway-conf\\\n     ```\n   - Create a ConfigMap and deploy the gateway:\n     ```bash\n     kubectl create cm books-gateway-conf --from-file gateway-conf/\n     kubectl create -f gateway-deployment.yml\n     ```\n\n### Step 5: Service Exposure and Load Balancing\n\n1. **Internal Exposure Using ClusterIP:**\n   - Expose each microservice internally:\n     ```bash\n     kubectl expose deploy books-api --port=8000\n     kubectl expose deploy clients-api --port=8000\n     ```\n\n2. **External Exposure Using LoadBalancer:**\n   - Provide external access through a LoadBalancer:\n     ```bash\n     kubectl expose deploy gateway-api --port=8000 --type=LoadBalancer\n     ```\n   - Access the services externally using the provided IP:\n     ```\n     http://\u003cexternal-ip\u003e:8000/docs\n     ```\n\n### Step 6: Implementing NGINX Ingress Controller and Ingress Rules\n\n- **Installing NGINX Ingress Controller**\n  - Using Helm to install:\n    ```bash\n    helm install my-nginx bitnami/nginx-ingress-controller --set rbac.create=true\n    ```\n\n- **Configuring and Applying Ingress Rules**\n  - Apply limits to prevent abuse:\n    ```bash\n    kubectl apply -f ingress-limiter.yml\n    ```\n\n- **Monitoring and Troubleshooting**\n  - Commands to monitor and troubleshoot ingress setup:\n    ```bash\n    kubectl get ingress\n    kubectl logs -n \u003cnamespace\u003e -l app=nginx-ingress --tail=100\n    ```\n\n## Additional Resources\n\n- For a complete list of commands used and step-by-step guidance, check the `assets` folder where you can find the `commands.txt` and a detailed PDF.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafavermar%2Fterraform_eks_fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafavermar%2Fterraform_eks_fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafavermar%2Fterraform_eks_fastapi/lists"}