Git Product home page Git Product logo

lambdatoauroranovpc's Introduction

AWS Lambda to AWS RDS without VPC

More info here: https://coderecipe.ai/architectures/77374273

Background

Problem Statement:

Traditionally, in order to have lambda talking to RDS one would have to introduce a VPC in between, this is problematic because:

  • VPC cold start time takes seconds!

  • Complexity of setting up and maintaining a VPC is really unnecessary

  • VPC is not free either!

Solution:

Using the new Data API provided by AWS Aurora (currently still in beta), an AWS Lambda can directly communicate with the RDS Instance. The Lambda is then connected to an API Gateway to allow user interface.

Functional Requirements:

Be able to query an RDS instance from within a AWS Lambda function without the use of VPC.

Performance Requirements:

Avoid performance issues caused by VPC configuration.

Recipes built on top of this recipe:

How I Build a Scalable Crypto Exchange with AWS and web3.js

Note:

One note about using the Data API is that the sql query being sent over is taken in as raw input and could potentially introduce SQL injection vulnerability. To avoid this, we have sanitized the inputs using mysql.escape.

Prerequisites

npm install serverless-python-requirements npm install serverless-pseudo-parameters npm install serverless-iam-roles-per-function npm install serverless-plugin-scripts

pip install -r requirements.txt

Deploy

serverless deploy --stage <stage_name> --dbUser <db_user>

Create DB - Must be done before using app

sls invoke -f AuroraCRUD -d '{"body":{"eventType":"createTable"}}' -l --stage <stage_name> --dbUser <db_user>

lambdatoauroranovpc's People

Contributors

coderecipe-dev avatar

Watchers

James Cloos avatar Dasith Kuruppu avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.