Dynamic AWS Lambdas
Luis F. Majano
LUIS F. MAJANO
• CEO Ortus Solutions
• Computer Engineer
• Born in El Salvador => Raised in the USA
• 2023 Leading EU Expansion team (Malaga, Spain 🇪🇸)
• Creator & Maintainer:
ColdBox MVC, TestBox BDD/TDD, CommandBox CLI, ContentBox CMS, etc.
• Creator / Chief Language Engineer BoxLang Programming Language
@lmajano @ortussolutions
Who we are?
Who we are?
• Ortus is a professional open-source and services company since
2006
• Full gammut of Polyglot developers
(Java, Groovy, Rust, Python, Scala, CFML, NodeJS, PHP)
• Creators of all major frameworks for the ColdFusion/CFML eco-system
• CLI, MVC, DI/AOP, CMS, Testing TDD/BDD, Package Manager, etc
• Manage over 350+ libraries
• 19+ years of servicing di
ff
erent software communities globally
• We create tools and custom solutions!
• Specialize on custom software and design!
20 Minute Agenda
• AWS Lambda
• Simple Intro
• Our Use Case
• BoxLang
• What is it?
• Lambda Runtime
• Lambda Template
• try.boxlang.io
https://www.youtube.com/ortussolutions
AWS Lambda - Serverless Computing
FaaS
AWS Lambda is a serverless computing service that runs
code in response to events without managing servers,
automatically scaling and charging only for execution time.
Serverless Review
Execution Patterns
• API Driven Patterns
• Event Driven Patterns
• Data Streaming Patterns
• Scheduling Patterns
Execution Patterns
• API Driven Patterns
• Event Driven Patterns
• Data Streaming Patterns
• Scheduling Patterns
How Serverless Functions Work
Upload Function
(CI, Manually)
De
fi
ne Function Triggers
(API Calls, Events, Schedules)
Function Execution
(Stateless, Cold Start, Timeouts)
Key Points About Serverless
• Focus on code abstractions
• Provider
• Auto Scaling
• Fault tolerance
• High Availability
• Metrics and Logging
• No OS updates
• Pay per use ONLY
Common Use Cases
REST Data Processing
Chat Bots
Amazon Alexa IoT
Scheduled Tasks Code Execution AI
Common Use Cases
Code Execution
DYNAMIC : MODULAR : PRODUCTIVE
BoxLang is a modular dynamic language for the JVM, aiming
to make your development more productive, expressive,
functional, and available everywhere.
DYNAMIC : MODULAR : PRODUCTIVE
• Small, lightweight, and modular (<8 MB)
• Multi-Runtime & Multi-Parser
• Dynamically Typed with an optional/inferred/coercion type system
• Language supports Classes, Scripting, and Templating Language
• Modern Java interop (InvokeDynamic)
• Highly functional: context-aware closures, pure lambdas, and more
• Built-in Framework concerns
• Open Source + FREE 🎉
What is it?
BoxLang Framework
RUNTIME
Application
Service
Async
Service
Cache
Service
Component
Service
Datasource
Service
Function
Service
Interceptor
Service
Module
Service
Scheduler
Service
Key Features
• 100% Java interop
• Auto Casting, type promotions, type contagion
• Extend Java, Implement Java, Import Java
• Classes (full OO, interfaces, abstract, static, etc)
• Closures and Pure Functions
• Unmodi
fi
able Types (Query, Array, Struct)
• Event-Driven Language
• Caching Engine + API
• Scheduled Tasks
Key Features
• Member functions
• Meta programming
• Array/Struct Change Listeners
• Extend via Modules (50+)
Key Features
• Extremely well-documented
• boxlang.ortusbooks.com
BoxLang Lambda Runtime
BoxLang Lambda Runtime
• Leverages the AWS Java SDK
• BoxLang implements the AWS Runtime Handler for you
• Bootstraps the runtime (Con
fi
gurations + Modules + Dependencies)
• Tuned for fast startups
• Tuned for fast coding
Lambda Flow
• Lambda Handler:
• ortus.boxlang.runtime.aws.LambdaRunner
:
:
handleRequest
• Acts as a Front Controller
• Inspects incoming Request
• Routing built-in (classes or functions)
• Automatic logging, error handling, life-cycle events
• Delegates to the appropriate BoxLang Class + Function
• Automatic response handling
BoxLang Lambda Handler
• Focus on your Function, not the boilerplate
• Implement Handlers as BoxLang Classes
• Class by Convention: Lambda.bx
• 1 method by convention: run( event, context, response )
• 1 Optional Application.bx for life-cycles or activating framework features
BoxLang Handlers
• Run() function by convention
• Event = Struct of the request
• Context = AWS Context Object
• Response = Struct of response data (optional)
• Return:
• Nothing (Use the response struct)
• Simple Value
• Complex Values
BoxLang Lambda
BoxLang Lambda
• A Struct (case-insensitive map)
• Lambda Invocation Types
• Manual input
• Function URL Request
BoxLang Event Struct
https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/my/path",
"rawQueryString": "parameter1=value1&parameter1=value2&parameter2=value",
"cookies": [
"cookie1",
"cookie2"
],
"headers": {
"header1": "value1",
"header2": "value1,value2"
},
"queryStringParameters": {
"parameter1": "value1,value2",
"parameter2": "value"
},
"requestContext": {
"accountId": "123456789012",
"apiId": "<urlid>",
"authentication": null,
"authorizer": {
"iam": {
"accessKey": "AKIA
.
.
.
",
"accountId": "111122223333",
"callerId": "AIDA
.
.
.
",
"cognitoIdentity": null,
"principalOrgId": null,
"userArn": "arn:aws:iam
:
:
111122223333:user/example-user",
"userId": "AIDA
.
.
.
"
}
},
"domainName": "<url-id>.lambda-url.us-west-2.on.aws",
"domainPrefix": "<url-id>",
"http": {
"method": "POST",
"path": "/my/path",
"protocol": "HTTP/1.1",
"sourceIp": "123.123.123.123",
"userAgent": "agent"
},
"requestId": "id",
"routeKey": "$default",
"stage": "$default",
• A Java object
• com.amazonaws.services.lambda.runtime.Context
AWS Lambda Context
https://docs.aws.amazon.com/lambda/latest/dg/java-context.html
• We build the response object for you according to your return
• Return:
• Nothing (Use the response struct)
• statusCode: numeric
• headers: struct
• Body: anything
• Cookies : array
• Simple Value
• Complex Values
AWS Lambda Response
• Lambda must be exposed as a URL
• Run() function by convention
• Add as many public functions as you want
• Execute them via the x-bx-function header
Lambda Multi-Function Routing
• Class Routing by Convention
• `/{ClassName}` -> ClassName.run()
• / -> Lambda.bx
• /products -> Products.bx
• /services -> Services.bx
Multi-Lambda Routing
BoxLang Lambda Template
• Turnkey Template for Lambda Development
• Unit + Integration Testing
• JUnit/TestBox + SAM
• Gradle
• Java Dependencies + Packaging + Testing
• CommandBox
• BoxLang Dependencies
• Github Actions CI
• Testing -> Packaging -> Deployment
https://github.com/ortus-boxlang/bx-aws-lambda-template
Package
Ortus Use Case : BoxLang Code Playground : try.boxlang.io
Wanna play?
64MB RAM
600 KB
8 MB
<Your
Code>
Wanna play?
• try.boxlang.io
• Internet playground for BoxLang
• First production BoxLang applications
• Powered by our MiniServer and AWS
Lambda Runtimes
Cool Stats
• Average executions per day: 32,000+
• Average execution time: 32ms
• Monthly Bill ????
$0.0000000000
Getting Started
Try Boxlang
An online code playground built
on the MiniServer + AWS Lambda
Runtimes.
Docs
Learn about BoxLang, and contribute
to our extensive documentation.
Community
Join our community and get help,
tips and more.
x.com/tryboxlang
www.boxlang.io
linkedin.com/company/tryboxlang
facebook.com/tryboxlang
youtube.com/ortussolutions
Questions?
THANK YOU

BoxLang Dynamic AWS Lambda - Japan Edition

  • 1.
  • 2.
    LUIS F. MAJANO •CEO Ortus Solutions • Computer Engineer • Born in El Salvador => Raised in the USA • 2023 Leading EU Expansion team (Malaga, Spain 🇪🇸) • Creator & Maintainer: ColdBox MVC, TestBox BDD/TDD, CommandBox CLI, ContentBox CMS, etc. • Creator / Chief Language Engineer BoxLang Programming Language @lmajano @ortussolutions
  • 3.
  • 4.
    Who we are? •Ortus is a professional open-source and services company since 2006 • Full gammut of Polyglot developers (Java, Groovy, Rust, Python, Scala, CFML, NodeJS, PHP) • Creators of all major frameworks for the ColdFusion/CFML eco-system • CLI, MVC, DI/AOP, CMS, Testing TDD/BDD, Package Manager, etc • Manage over 350+ libraries • 19+ years of servicing di ff erent software communities globally • We create tools and custom solutions! • Specialize on custom software and design!
  • 5.
    20 Minute Agenda •AWS Lambda • Simple Intro • Our Use Case • BoxLang • What is it? • Lambda Runtime • Lambda Template • try.boxlang.io https://www.youtube.com/ortussolutions
  • 6.
    AWS Lambda -Serverless Computing FaaS
  • 7.
    AWS Lambda isa serverless computing service that runs code in response to events without managing servers, automatically scaling and charging only for execution time. Serverless Review
  • 8.
    Execution Patterns • APIDriven Patterns • Event Driven Patterns • Data Streaming Patterns • Scheduling Patterns
  • 9.
    Execution Patterns • APIDriven Patterns • Event Driven Patterns • Data Streaming Patterns • Scheduling Patterns
  • 10.
    How Serverless FunctionsWork Upload Function (CI, Manually) De fi ne Function Triggers (API Calls, Events, Schedules) Function Execution (Stateless, Cold Start, Timeouts)
  • 11.
    Key Points AboutServerless • Focus on code abstractions • Provider • Auto Scaling • Fault tolerance • High Availability • Metrics and Logging • No OS updates • Pay per use ONLY
  • 12.
    Common Use Cases RESTData Processing Chat Bots Amazon Alexa IoT Scheduled Tasks Code Execution AI
  • 13.
  • 14.
    DYNAMIC : MODULAR: PRODUCTIVE
  • 15.
    BoxLang is amodular dynamic language for the JVM, aiming to make your development more productive, expressive, functional, and available everywhere. DYNAMIC : MODULAR : PRODUCTIVE
  • 16.
    • Small, lightweight,and modular (<8 MB) • Multi-Runtime & Multi-Parser • Dynamically Typed with an optional/inferred/coercion type system • Language supports Classes, Scripting, and Templating Language • Modern Java interop (InvokeDynamic) • Highly functional: context-aware closures, pure lambdas, and more • Built-in Framework concerns • Open Source + FREE 🎉 What is it?
  • 17.
  • 18.
    Key Features • 100%Java interop • Auto Casting, type promotions, type contagion • Extend Java, Implement Java, Import Java • Classes (full OO, interfaces, abstract, static, etc) • Closures and Pure Functions • Unmodi fi able Types (Query, Array, Struct) • Event-Driven Language • Caching Engine + API • Scheduled Tasks
  • 19.
    Key Features • Memberfunctions • Meta programming • Array/Struct Change Listeners • Extend via Modules (50+)
  • 20.
    Key Features • Extremelywell-documented • boxlang.ortusbooks.com
  • 21.
  • 22.
    BoxLang Lambda Runtime •Leverages the AWS Java SDK • BoxLang implements the AWS Runtime Handler for you • Bootstraps the runtime (Con fi gurations + Modules + Dependencies) • Tuned for fast startups • Tuned for fast coding
  • 23.
  • 24.
    • Lambda Handler: •ortus.boxlang.runtime.aws.LambdaRunner : : handleRequest • Acts as a Front Controller • Inspects incoming Request • Routing built-in (classes or functions) • Automatic logging, error handling, life-cycle events • Delegates to the appropriate BoxLang Class + Function • Automatic response handling BoxLang Lambda Handler
  • 25.
    • Focus onyour Function, not the boilerplate • Implement Handlers as BoxLang Classes • Class by Convention: Lambda.bx • 1 method by convention: run( event, context, response ) • 1 Optional Application.bx for life-cycles or activating framework features BoxLang Handlers
  • 26.
    • Run() functionby convention • Event = Struct of the request • Context = AWS Context Object • Response = Struct of response data (optional) • Return: • Nothing (Use the response struct) • Simple Value • Complex Values BoxLang Lambda
  • 27.
  • 28.
    • A Struct(case-insensitive map) • Lambda Invocation Types • Manual input • Function URL Request BoxLang Event Struct https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html { "version": "2.0", "routeKey": "$default", "rawPath": "/my/path", "rawQueryString": "parameter1=value1&parameter1=value2&parameter2=value", "cookies": [ "cookie1", "cookie2" ], "headers": { "header1": "value1", "header2": "value1,value2" }, "queryStringParameters": { "parameter1": "value1,value2", "parameter2": "value" }, "requestContext": { "accountId": "123456789012", "apiId": "<urlid>", "authentication": null, "authorizer": { "iam": { "accessKey": "AKIA . . . ", "accountId": "111122223333", "callerId": "AIDA . . . ", "cognitoIdentity": null, "principalOrgId": null, "userArn": "arn:aws:iam : : 111122223333:user/example-user", "userId": "AIDA . . . " } }, "domainName": "<url-id>.lambda-url.us-west-2.on.aws", "domainPrefix": "<url-id>", "http": { "method": "POST", "path": "/my/path", "protocol": "HTTP/1.1", "sourceIp": "123.123.123.123", "userAgent": "agent" }, "requestId": "id", "routeKey": "$default", "stage": "$default",
  • 29.
    • A Javaobject • com.amazonaws.services.lambda.runtime.Context AWS Lambda Context https://docs.aws.amazon.com/lambda/latest/dg/java-context.html
  • 30.
    • We buildthe response object for you according to your return • Return: • Nothing (Use the response struct) • statusCode: numeric • headers: struct • Body: anything • Cookies : array • Simple Value • Complex Values AWS Lambda Response
  • 31.
    • Lambda mustbe exposed as a URL • Run() function by convention • Add as many public functions as you want • Execute them via the x-bx-function header Lambda Multi-Function Routing
  • 32.
    • Class Routingby Convention • `/{ClassName}` -> ClassName.run() • / -> Lambda.bx • /products -> Products.bx • /services -> Services.bx Multi-Lambda Routing
  • 33.
    BoxLang Lambda Template •Turnkey Template for Lambda Development • Unit + Integration Testing • JUnit/TestBox + SAM • Gradle • Java Dependencies + Packaging + Testing • CommandBox • BoxLang Dependencies • Github Actions CI • Testing -> Packaging -> Deployment https://github.com/ortus-boxlang/bx-aws-lambda-template
  • 34.
  • 35.
    Ortus Use Case: BoxLang Code Playground : try.boxlang.io
  • 36.
    Wanna play? 64MB RAM 600KB 8 MB <Your Code>
  • 37.
    Wanna play? • try.boxlang.io •Internet playground for BoxLang • First production BoxLang applications • Powered by our MiniServer and AWS Lambda Runtimes
  • 38.
    Cool Stats • Averageexecutions per day: 32,000+ • Average execution time: 32ms • Monthly Bill ???? $0.0000000000
  • 39.
    Getting Started Try Boxlang Anonline code playground built on the MiniServer + AWS Lambda Runtimes. Docs Learn about BoxLang, and contribute to our extensive documentation. Community Join our community and get help, tips and more. x.com/tryboxlang www.boxlang.io linkedin.com/company/tryboxlang facebook.com/tryboxlang youtube.com/ortussolutions
  • 40.