百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fastapi-serverless-aws-backend-service

> 后端框架
开源

搭载多阶段 CI/CD 部署的 FastAPI Python 后端服务器

100 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

搭载多阶段 CI/CD 部署的 FastAPI Python 后端服务器

FastAPI Serverless AWS Backend Server

This project act as a template for a FastAPI server deployed on AWS Lambda for production use.

Features

  • Project structure template
  • FastAPI boiler plate code:
    • Root application with versioning API (currently V1 and V2 are defined)
    • Middleware for CORS, exceptions and logging
    • Config module with settings loaded from your .env file
    • Logs are working also in production environment (AWS Lambda)
    • Test suite setup with TestClient
    • Health check route and exceptions routes
  • Python code quality tools already setup both locally and as part of the CI (Pylint, Black, Isort, MyPy)
  • Dockerfile with AWS lambda base image for the FastAPI service container
  • Poetry for python environment management
  • Serverless.yml boiler plate:
    • Lambda function for the FastAPI backend service
    • Lambda is container-based and images are deployed to AWS ECR
    • Defined cloud watch IAM roles and retention policy (30 days)
    • Defined XRay IAM roles
    • Custom domain management support in three sub-domains, one per stage.
  • Scripts folder so you can easily run it all

Future Features

  • boiler plate code for caching using FastAPI_Cache
  • Basic authentication and authorization with Auth0
  • Database migration support using Alembic

Prerequisites

  • An AWS account
  • The AWS CLI installed and configured
  • Python 3.7.2 or later
  • Poetry for managing dependencies and packaging the app
  • npm for installing the serverless framework and plugins
  • serverless framework for deploying the backend (just run npm install -g serverless)
  • Docker for building and testing the app locally
  • (Optional) An AWS Certificate of SSL/TLS certificate for a domain name in the AWS Certificate Manager (this guide can help)

Getting Started

  1. Clone the repository
bash
git clone https://github.com/larium/fastapi-serverless-aws-backend.git
  1. Install the dependencies
bash
cd fastapi-serverless-aws-backend
npm install
poetry install
  1. Set up local environment in .env file
  • Create the file: touch .env
  • Set the following values inside:
TBA
  1. Set access permissions to scripts directory
bash
chmod 777 ./scripts/*
  1. Run local code analysis
./scripts/check
  1. Run local tests
./scripts/test
  1. Run local server
./scripts/start

Test it curl --request GET "https://localhost:8000"

  1. (Optional) If you want to use a custom domain for the backend, follow these steps:
  • Obtain an ARN of AWS Certificate for your domain in the AWS Certificate Manager
  • Set it on the .env file in ACM_ARN
  • In serverless.yml -> set customDomain.enabled: true
  • Update the value of baseDomain with your base domain
  • Create the domain (this link a Route53 rule to the Certificate)
./scripts/create-domain
  • Next time you will deploy the server will be exposed under your domain.
  1. Deploy to AWS
./scripts/deploy

Test it curl --request GET "https://.execute-api..amazonaws.com/dev/"

  1. Remove deployment from AWS
./scripts/remove
  1. (Optional) Remove the domain from Route53 (it will not remove the certificate!)
./scripts/delete-domain

Environments

What How (script) Where (endpoint)
Local ./scripts/start http://localhost:8000
Remote ./scripts/deploy https://***.execute-api..amazonaws.com/dev/
Develop Domain ./scripts/create-domain``./scripts/deploy https://api-develop.your.domain
Staging Domain ./scripts/create-domain staging``./scripts/deploy staging https://api-staging.your.domain
Production Domain ./scripts/create-domain prod``./scripts/deploy prod https://api.your.domain

Contributing

We welcome contributions to this project! If you have an idea for a new feature or improvement, please open an issue or pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Tips

Set python interpreter in VScode

  • Run poetry run which python and copy the python path
  • command+shift+p to open the VScode command shortcuts and enter Python: Select Interpreter
  • Select + Enter interpreter path... and paste the python path
  • That's it.

Issues· 2 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonaws-lambdacicdfastapipython

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架