Lambda function to access RDS, S3. And, Eventbridge in AWS

Himanshu Singh
6 min readSep 15, 2024

Hello everyone đź‘‹,
I am Himanshu Singh. I am an Engineer and recently after working as a frontend engineer for more than 2 years, I started doing full-stack. I was recently given a task where I had to write a lambda function to query DB, prepare a CSV document with it, and store that document on S3, and using Eventbridge, I had to create a scheduler to invoke this function weekly.

And in last, my senior also asked me to push all the lambda code on GitHub and write a GitHub action to push the changes to lambda on AWS. So, we won’t need to open AWS to make any changes to the code itself.

We wanted to automate all these parts of the job.

I could have done better on this task. I used ChatGPT often, asked my senior many queries, and finally raised a PR.

So I thought of writing a blog about exactly what I did.

Let’s begin!

Write the lambda function

Writing the function itself was not that difficult, but connecting to the DB without credentials was something.

In the lambda function, to do the connection, I wrote a function connectToDB()which you can find below

import { Signer } from “@aws-sdk/rds-signer”…

--

--

Himanshu Singh

I write blogs around React JS, JavaScript, Web Dev, and Programming. Follow to read blogs around them.