I am new to AWS and trying to run a function on it that I currently use on Heroku. It is an app that runs each morning and uses node and Twilio. When trying to add this to AWS, I can only find tutorials and help online that shows how to use this as if it were a endpoint. It requires me to return json data instead of running the script as a cli app like it currently does on heroku. Any suggestions with this? Is this not part of what AWS lambda functions can do and I should be trying a different tool?
You can trigger lambda manually or on schedule with Cloudwatch events. You can also have it probe a queue for work. Not sure what you are trying to do but try googling the above ![]()
I’m not sure exactly what you’re trying to achieve with running a lambda as a cli command but if it’s a scheduled job that runs each day at a specific time you should probably look in to using something like the following:
- lambda function for code. Code stored in S3 bucket.
- Cloudwatch scheduled event to trigger it as a cron.
That way you’re input will be a Cloudwatch event and you probably don’t need an output. Just log whatever you need to Cloudwatch logs.
Feel free to pm if you want any more support. Maybe I can throw something together with the cdk for you to automate your deployments / updates.
I may have the terminology wrong, will PM with a little more clarification
Just finished reading on Cloudwatch and this will come in handy once I get it up and running. Thank you for this!
Not quite sure why you need to store code in S3 bucket? Is this part of IaC that you’re talking about?
Lambda can easily be used without returning http - simply add your code (plus dependencies if needed) and invoke. You can use CloudWatch Events to schedule Lambda per this article.
The Lambda function can do its thing and exit without sending output anywhere. Logging is by default sent to CloudWatch Logs (assuming the function’s IAM role has permission to do so).
You can use a Cloudwatch event to trigger the lambda function daily. Cloudwatch events was renamed to EventBridge recently but both service names still exist in the console which may confuse you a little bit. You can use the terms Cloudwatch Events and EventBridge interchangeable. May help if you’re are searching docs etc.
You can return whatever you like but if you’re not planning to process that response just return a JSON object on success that says job was successful or something arbitrary.
They can have many types of triggers from cron times to other resource events or manual invokes etc