Skip to content

A template to create your AWS Lambda function using Node.js. It covers how to connect to a PostgreSQL database, write queries, fetch results, and send a request to the desired endpoint.

Notifications You must be signed in to change notification settings

ayusharma-ctrl/AWS-Lambda-Node-PostgreSQL-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

AWS-Lambda-Node-PostgreSQL-Template

A template to create your AWS Lambda function using Node.js. It covers connecting to a PostgreSQL database, writing queries, fetching results, and sending a request to the desired endpoint.

  1. Create an 'index.js' file.
  2. Install the pg module using the command 'npm install pg' – this will generate the 'node_modules' folder and a 'package-lock.json' file.
  3. Define the exports.handler method to execute the code.
  4. Add and import all variables related to your server and database.
  5. Establish a connection with your database.
  6. Write a query and fetch the data.
  7. Disconnect from the database if access is no longer needed.
  8. Implement another method to send a request to your server's endpoint.
  9. Once you have finished writing the code, compress the contents of your project's root folder and upload the zip file to your Lambda function.
  10. Create a new scheduler in Amazon EventBridge to trigger this Lambda function.

About

A template to create your AWS Lambda function using Node.js. It covers how to connect to a PostgreSQL database, write queries, fetch results, and send a request to the desired endpoint.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published