AWS Lambda Quick REcap
- To be able to invoke Lambda via HTTP, need to setup a URL in API Gateway. The URL can then be invoked
logging
module to write message to the logs, you also get some additional information in the log such as the time stamp and the log levels. The log level identifies the type of log, such as[INFO]
,[ERROR]
, and[DEBUG]
.
You can also find these logs in CloudWatch.
List all LAmbdas on your account
- In order to solve this problem, Epsagon has created an open-source project: list-lambdas. It’s a Python script which enumerates your Lambda functions across all AWS regions and provides useful information, such as the function’s memory settings, its
Use Cases
- Monitor an HTTPS Endpoint (using Lambda and Cloudwatch).
- Step 1 –> Create ROLE (programmatic Identity) –> IN creating ROLE, add ‘Create Policy –> CloudWatch—> PutMetricData from the Write Permissions
- To run this periodically, create a Cloudwatch Rule –> Now that the Lambda script has been set up, you only need to make sure it gets run every five minutes (or any other interval you prefer). This is possible with CloudWatch Rules. Go to the CloudWatch service from your AWS dashboard and select “Rules” from the left-hand menu. Click on “Create rule” and select “Schedule” as yo
To Prevent DDOS attack
- Enable AWS Shield Standard – place Lambda on CloudFront – Anything behind Shield gets protected from DDOS;
- Alternatively, host the URL in API Gateway and throttle the gateway as needed
Event Loops Lambda
The default behavior is that Lambda will wait for all scheduled work (work queued up in the event loop) to complete before allowing the next request to get called in a particular instance. In the case of our code that means Lambda will wait for the final saveImage()
callback to fire before allowing another request through. However, it could be that the work we’re still performing is fine to run at the same time as the normal request handler. Luckily, we can override this behavior by changing the context.callbackWaitsForEmptyEventLoop
flag, which has a default value of true, to false.
Leave a Reply