Serverless is awesome. The ability to run a snippet of code in the cloud in response to various triggers without having to manage infrastructure is beyond amazing especially if you don’t want to take on to much technical debt.
One big gotcha with Serverless offerings such as AWS Lambda is how do you test your code if its running on some magical box in the cloud? Whilst there exists projects like lambda-local to test locally, I prefer to test on the environment in which its going to be deployed. Testing in the cloud becomes more important if the function depends on some other AWS resources that aren’t accessible outside of your VPC.
My workspace for this kind of workflow usually has a few scripts per function,
This script is dead simple and fairly dependant on the language you are working with. The example I have included is suited for Python 3.6 but should be easily adapted to suit other languages. It zips up the source code and sends it off to AWS using the CLI.
run.sh - via AWS CLI
A simple wrapper around
aws lambda invoke to make life a little easier. Payload is supplied via the
run.sh - via API gateway
Heres the fun stuff, this script depends on the awesome awslogs package and that your function
is connected to an API Endpoint via API Gateway. Payload is supplied via the
comments powered by Disqus