Reputation: 11
I have an app that uses puppeteer
to scrape through a website (log in, book some reservations, log out). The app uses a mongodb
database to get the data it needs to log in and book reservations, and then store new data based on its success in completing those tasks.
I need this app to run everyday (i.e. 5:00 AM
each day). I want to use AWS
in order to automate this process instead of having to tell my own computer to run the app each day. I'd like to be able to use AWS to host my website, access my mongodb
atlas database, and run my node.js
script.
After some research it looks like AWS Lambda will be the simplest way to get my app online. I have already built the app so it executes on my local computer with a simple node
app.js
command. My question is how do I link/upload my node index.js
file to Lambda. I selected a simple "hello world" framework and see where an index.js
file on lambda has been created with an exports.handler
function inside it.
Do I need to copy and paste my local app.js
file (the one that runs the app) into this index.js
file on Lambda (that's several hundred lines of code and it needs to access a mongodb
atlas database), or can I put a line of code inside the Lambda index.js
file to call my app.js
file (after I upload it). If I can call app.js
inside the exports.handler
, then what line of code would I need?
Upvotes: 0
Views: 137
Reputation: 366
I recommend checking the CDK workshop on: https://cdkworkshop.com/. It is a short intro which also goes throught how to setup a small stack using lambda and apigateway. Going through it will probably answer many of the questions you have.
Upvotes: 1