Building Dynamic APIs with BoxLang on AWS Lambda for Modern Serverless Applications
Explore creating efficient APIs using BoxLang in AWS Lambda, covering serverless architecture, event-driven models, routing, and performance considerations for modern software development.
• CF /BoxLang user for about 25 yrs
• Interests: Site Modelling, Testing, Driving my son to activities
dcard@ortussolutions.com
Dan Card
Senior Developer, Ortus Solutions
4.
w w w.i n t o t h e b o x . o rg
GET STARTED
Creating Your API With BoxLang
In AWS Lambda
5.
What is Lambda
AWSLambda is an event-driven, serverless compute
service that allows you to run code without provisioning
or managing servers. You simply upload your code, and
Lambda handles the infrastructure, scaling, and high
availability automatically
6.
Comparing the TwoModels
Always On
Full Computer with OS and
whatever you put on it
Lambda
Deliberately On Or Off
Your Code and your code alone
“Off by Default”
On when it is triggered, it runs,
and then turns off
7.
The Ripples Fromthose conditions
• Financial: You’re charged in seconds or milliseconds, not
hours or days
• Great for R&D, small / non-revenue projects
• Financial: You can’t forget to turn it off
• User Experience: Your call to the API, ON A COLD START, is…
• The time it takes for the event to register PLUS
• The time for the language server to start PLUS
• The time for any framework to spin up PLUS
• The time for the code to run PLUS
• The packet roundtrip time
8.
Let’s Break ThatDown
The time it takes for the event to
register
The time for the language server to
start
The time for any framework to spin up
The time for the code to run
The packet roundtrip time
Negligible and “a wash”
Boxlang makes that possible
Not using a framework – No
Coldbox
“A wash”
“A wash”
Key Keys inEvent
•queryStringParameters – struct of the URL
•Body – the body of the request
• Gotcha: Need a Content-Type: application/json
•rawPath – The raw path of the request
•Headers – a struct of the headers from the
request
15.
Routing
• Almost nomatter what it’s going to call the Lambda.bx run
function
• Use the x-bx-function=methodName to a different
function in the same file
• Use Single level path to run another class ( i.e. MyProduct )
run()