Skip to content

Commit 2b75e2a

Browse files
committed
docs: add request flow description & lib links
1 parent fd534eb commit 2b75e2a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
# AWS FastAPI Lambda
2-
Create an API using AWS API Gateway, Lambda and FastAPI + Mangum (based on [this walkthrough](https://towardsdatascience.com/fastapi-aws-robust-api-part-1-f67ae47390f9)):
2+
Creates an API using an AWS API Gateway and Lambda function, based on [this walkthrough](https://towardsdatascience.com/fastapi-aws-robust-api-part-1-f67ae47390f9). The setup uses:
3+
4+
* **API:** [FastAPI](https://fastapi.tiangolo.com/) `+` [Mangum](https://mangum.io/), served by [uvicorn](https://www.uvicorn.org/)
5+
* **Infrastructure:** [Terraform](https://www.terraform.io/) `+` [Terragrunt](https://terragrunt.gruntwork.io/)
6+
7+
Requests are sent to the API Gateway, which has one `/{proxy+}` resource. This resource handles all requests using a [proxy integration with the Lambda function](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html). Mangum acts as a wrapper, which allows FastAPI to handle the requests and create responses the API gateway can serve. All logs are sent to CloudWatch log groups.
38

49
```js
5-
┌─── AWS region ────────────────────────────┐
6-
│ ┌─── VPC ──────────────┐ │
7-
│ │ │ │
8-
Request ───► API Gateway ───► Lambda (FastAPI) │ │
9-
│ │ │ │
10-
│ │ └──────────│───────────┘ │
11-
│ ┌───────│───────────────────│───────────┐ │
12-
│ │ ▼ CloudWatch ▼ │ │
13-
│ └───────────────────────────────────────┘ │
14-
└───────────────────────────────────────────┘
10+
┌─── AWS region ────────────────────────────
11+
│ ┌─── VPC: three AZs ────┐ │
12+
│ │ │ │
13+
Request ───► API Gateway ───► Lambda (FastAPI) │ │
14+
│ │ │ │
15+
│ │ └──────────│───────────┘ │
16+
│ ┌───────│───────────────────│───────────┐ │
17+
│ │ ▼ CloudWatch ▼ │ │
18+
│ └───────────────────────────────────────┘ │
19+
└───────────────────────────────────────────
1520
```
1621

17-
* Lambda is deployed in a VPC, so the function has access to private resources.
18-
* No Internet Gateway, so Lambda uses VPC endpoints for access to CloudWatch.
22+
If performance becomes an issue, a CloudFront distribution could be added for API responses that are cacheable.
1923

2024
# Dev
2125
```sh
@@ -32,7 +36,7 @@ View the [API endpoints](http://localhost:8000/docs).
3236
cd api
3337
make zip
3438

35-
# Create the API gateway and Lambda function
39+
# Create the AWS infrastructure
3640
cd ../infra/env/dev
3741
terragrunt run-all plan # to see all the goodness that will get created
3842
terragrunt run-all apply # create all the goodness

0 commit comments

Comments
 (0)