Skip to content

Latest commit

 

History

History

web-api-lambda-context

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Accessing Lambda Context from Api Builder Requests

This example shows how to access the Lambda Context Object from a web API built using claudia-api-builder'.

This might be useful if you want to access the internal Lambda request ID, log groups or streams automatically created for your Lambda function, or terminate the execution using some other mechanism, instead of the default API Builder workflow.

The context object is also useful if you want to detect which version of your function got called, for example if you're running multiple versions for development, testing and production. Check out the Detecting Context Example to see how you can use this to detect the version.

Try it out

Install the dependencies:

npm install

Deploy the API to AWS:

npm start

The deployer will print out the web API URL when it completes. Paste that in your browser or execute using CURL, and you'll see the Lambda context details

How it works

The Lambda context object gets assigned to request.lambdaContext (since claudia-api-builder 1.3.0), so you can just access all the context fields and methods directly. Check out web.js to see how it is actually used in the code.