Dash0 acquires Polar Signals

Last updated:

Lambda and RDS: Connecting Lambda Functions to RDS Instances

What Are AWS Lambda and RDS?

AWS Lambda is a widely used cloud computing service that allows developers to run code in a serverless cloud. It eliminates the need to provision or manage servers. The Relational Database Service (RDS) is a popular cloud service that provides managed SQL databases. RDS is server-based, so it requires provisioning and managing a server.

AWS Lambda and RDS can theoretically work together, but it is not straightforward to make them connect seamlessly. The different architectures (serverless vs. server-based) mean they have different requirements and need to be carefully configured.

This is part of our series of articles about AWS Lambda deployment.

Configuring a Lambda Function to Access Amazon RDS in an Amazon VPC

Create Role to Give Permissions

To create the execution role needed for granting permissions:

  1. Go to the IAM console on the AWS management console and click Roles on the left sidebar.
  2. Click the Choos****e role button.
  3. From the options under the Select type of trusted entity section, choose AWS Service, and choose Lambda under Choose the service that will use the role.
  4. Give lambda-demo-role as the role name.

Create Database Instance

This tutorial uses an Amazon RDS database instance. The Lambda function will facilitate access to this instance while in the Amazon VPC. The Lambda function will create a table called demoEmployee,insert some records, and retrieve them. The schema of the tables is as follows:

text
demoEmployee(demoEmployeeID, employeeName)

Here,

text
text
demoEmployeeID
Authors
Erez Berkner
Erez Berkner