AWS Lambda Functions
Lambda functions are just regular JS/TS code that AWS invokes.
- Virtual functions - no servers to manage! You don't provide a container or environment. just a single function that runs when an event triggers it.
- Limited by time - short executions - 15 min time limit of run time.
- Run on-demand. Event Drive, invoked when needed.
- integrated with all AWS services and all programming languages.
The "handler" is the entry point function (handler() in index.ts) that AWS calls with a JSON payload.
The entire repo is not uploaded to AWS, the app is compiled and the compiled code and dependencies are bundled in a zip file that is uploaded to AWS. (process defined in .github/workflows/deploy.yaml). ENV vars are defined in AWS console.
Lambda functions are reactive, they only run when something triggers them.
Since Lambda functions are typically smaller pieces of code that are shortlived a common thing to want to do with them is schedule them (relevant: cron jobs and scheduled tasks)
For this you have to pair Lambda Functions and trigger them with other AWS Services: Event Bridge / Cloudwatch events and SQS (for more robustness)
Event Bridge and Cloudwatch are the same thing. Cloudwatch is the original, older name when the service had less features.
Lambda Container Image
- The container image must implement the Lambda Runtime API
- ECS / Fargate is preferred for running arbitrary Docker images