AWS Lambda | API Gateway | VPC | RDS | NodeJS | TypeORM

WE(V) ARE(R)
2 min readApr 24, 2020

Problem Statement

Timeout issue when a user connects RDS MySQL (NodeJS — TypeORM) via Lambda + API Gateway.

Solution:

Let's create your VPC network as shown below.

Create your VPC network
AWS VPC Architecture for Lambda + EC2 + RDS — application

Step 1: Create an AWS API gateway

Enable route context to access the Lambda Functions

Step 2: Create a Lambda function & include trigger API gateway

Lambda Designer (Add a trigger for function)

Step 3: Attach the policy to grant access your VPC network via AWS Lambda

Enable policy to access the VPC network via Lambda Function

Step 4: Provide access to VPC & subnets via security groups (Enable RDS MySQL port — 3306)

Include VPC & Subnets — Lambda Function

Step 5: Serverless coding access the rds database via TypeORM

AWS Serverless Express — Enable context to call via Lambda Function
TypeORM — DB config.json

--

--