Skip to content

Commit

Permalink
🤖 Commiting publications metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Cox65 authored and Nicolas Laffargue committed Nov 2, 2023
1 parent 7229377 commit 7b33a8a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions article/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ title: ⚡ Serverless REST API on AWS with FastAPI ⚡
tags:
- Python
- AWS
canonicalUrl: https://medium.com/aws-tip/serverless-rest-api-on-aws-with-fastapi-bd9de11f925a
canonicalUrl: >-
https://medium.com/aws-tip/serverless-rest-api-on-aws-with-fastapi-bd9de11f925a
coverImage: >-
https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/articles/fastapi-serverless-aws/article/cover.png
https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/article/cover.png
publications:
- platform: devTo
- id: 1655283
url: >-
https://dev.to/coxhawk/serverless-rest-api-on-aws-with-fastapi-1gae-temp-slug-1504554
platform: devTo
published: false
- platform: hashnode
- id: 65441fbf87cb01c1e88c3733
url: TBD
platform: hashnode
publicationId: 62019a434efba97010a97bb9
---

Expand Down Expand Up @@ -39,7 +45,7 @@ Then you will have to install the **Serverless** framework via npm. See instruct

First of all, we will build our FastAPI application. Add **fastapi** dependency in your requirements.txt and install it.
Then you can create your FastAPI application:
[{"filename": "../fastapi_aws_starter_kit/fastapi_app.py"}]: 🎨
[{"filename": "../fastapi_aws_starter_kit/fastapi_app.py"}]: 🎨
<a href="https://github.com/DevWaveX/fastapi-aws-starter-kit/blob/main/fastapi_aws_starter_kit/fastapi_app.py" target="_blank">![🎨../fastapi_aws_starter_kit/fastapi_app.py](https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/article/carbon/rJ4aksZJYBCa5iaw4fBQ6R/fastapi_app.py.png)</a>

## Deploy FastAPI on AWS
Expand All @@ -51,13 +57,13 @@ To deploy our API in **AWS**, we will leverage **API Gateway** and **Lambda** se
In order to build the handler for our Lambda which will be called by our API Gateway, we will use [**Mangum**](https://github.com/jordaneremieff/mangum) which is an ASGI adapter for API Gateway and Lambda (perfect for our FastAPI application 🍾)

Add **mangum** to your dependencies and build the handler as follow:
[{"filename": "../fastapi_aws_starter_kit/handler.py"}]: 🎨
[{"filename": "../fastapi_aws_starter_kit/handler.py"}]: 🎨
<a href="https://github.com/DevWaveX/fastapi-aws-starter-kit/blob/main/fastapi_aws_starter_kit/handler.py" target="_blank">![🎨../fastapi_aws_starter_kit/handler.py](https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/article/carbon/jztwxJAPjYRQs2EymEpYWH/handler.py.png)</a>

### Configure serverless.yaml

Serverless configuration is pretty easy, here is what I did as a simple example:
[{"filename": "../serverless.yaml"}]: 🎨
[{"filename": "../serverless.yaml"}]: 🎨
<a href="https://github.com/DevWaveX/fastapi-aws-starter-kit/blob/main/serverless.yaml" target="_blank">![🎨../serverless.yaml](https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/article/carbon/tFbeeDNkLxFKC92zuz1Tsv/serverless.yaml.png)</a>

As you can see I’m using 2 plugins:
Expand All @@ -78,7 +84,7 @@ sls deploy

If you want to run your API in local, you have two options.
Either you can run an [**uvicorn**](https://www.uvicorn.org/) web server like this:
[{"filename": "../fastapi_aws_starter_kit/web_server.py"}]: 🎨
[{"filename": "../fastapi_aws_starter_kit/web_server.py"}]: 🎨
<a href="https://github.com/DevWaveX/fastapi-aws-starter-kit/blob/main/fastapi_aws_starter_kit/web_server.py" target="_blank">![🎨../fastapi_aws_starter_kit/web_server.py](https://github.com/DevWaveX/fastapi-aws-starter-kit/raw/main/article/carbon/77TUvpNML39LNxTCw4JdXs/web_server.py.png)</a>

Either, and this what I recommend as we are using Serverless, you can use **serverless-offline** plugin I just mentionned before.
Expand Down

0 comments on commit 7b33a8a

Please sign in to comment.