[AWS] Lambda: FastAPI ๋ถ์ด๊ธฐ
FastAPI๋ magnum์ด๋ผ๋ ์๋ํํฐ๋ฅผ ํตํด ๋ฐ๋ก Lambda์ ๋ถ์ฌ์ ์ธ ์๊ฐ ์๋ค.
Lambda ์ธํ
๋จผ์ ํจ์๋ฅผ ๋ง๋ ๋ค.

๊ทธ๋ฆฌ๊ณ ๋ชจ๋์ ์ ์ ํ ๊น์์ Lambda์ ๋ฐ์ ๋ ์ด์ด๋ก ๋ง์์ค๋ค.
fastapi>=0.65.2
pydantic>=1.8.2
uvicorn>=0.11.7
mangum==0.17.0
https://blog.naver.com/sssang97/223199232880
์ ๋ก๋ํด์ ๋ ์ด์ด ๋ฑ๋กํด์ฃผ๊ณ

๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํด์ค๋ค.
from fastapi import FastAPI
from mangum import Mangum
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/health")
async def health_check():
return {"message": "OK"}
lambda_handler = Mangum(app, lifespan="off")API Gateway
์ด๊ฒ ๋์ ์๋๋ค.
Web API ํํ๋ก ํธ์ถํ ์ ์๊ฒ๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ํ์ค์ผ ํ๋ค.
https://blog.naver.com/sssang97/223098812722
Rest API Gateway๋ก ํ์ค ๋ค์์, ๋ค์๊ณผ ๊ฐ์ ํํ๋ก ๋ฆฌ์์ค๋ฅผ ์ ์, ๋๋คํจ์๋ฅผ ์ฐ๋ํ๋ค.

๊ทธ๋ฆฌ๊ณ ๋ฐฐํฌ๋ฅผ ๋์ฐ๋ฉด

ํด๋น ๋ฐฐํฌ ์คํ ์ด์ง๋ฅผ ํตํด ์ ์์ด ๊ฐ๋ฅํด์ง ๊ฒ์ด๋ค.


์ฐธ์กฐ
https://www.deadbear.io/simple-serverless-fastapi-with-aws-lambda/