This presentation covers techniques for building an AWS Lambda test harness application, allowing for local development and debugging of AWS Lambda functions.
2. Agenda:
● AWS Lambda Overview
● Debugging AWS Lambda
● Building a local test harness
● Deployment with Backand CLI
● Quick overview of Backand
3. AWS Lambda
● Created in 2014, launched at
re:Invent
● Kicked off "serverless" (caveat)
● Function-as-a-Service
○Deploy code, not applications
4. Creating A Lambda Function
● Supports Node.JS, Python, C#, and
Java
○ Can call to server functionality (Linux)
● Code deployment options
○ Uploading as a ZIP file
○ Uploading from S3
○ Editing in in-browser editor
7. Debugging Lambda Functions
● Cloudwatch Integration
○ Provides call record
● console.log()
○ Sends message to Cloudwatch
● … and that's it
8. Lambda Execution Environment
● Details kept proprietary by Amazon
● Based on Amazon Machine Instance
● Dynamically provisioned (hot vs cold)
● Temporary storage (/tmp, 500 MB)
○ NOT guaranteed to persist
9. Debugging Lambda Locally
● Need to mimic input format
● Need to mimic output format
○ Transformations in API Gateway
● Need a test harness
10. Creating a Test Harness
● Function Prototype
● Including Handler
● Mimicking Lambda Invocation
○ Parameters in event object
○ Handlers in the context object
11. Creating a Test Harness
● Calling a Lambda function, continued:
● Provide handlers in context argument
12. Test Harness Notes
● Callback mechanism provided by Lambda
○ Only supported by Node.JS actions
● Using callbacks in context parameter
○ Not officially supported
● Not a perfect substitute
○ Calls the function, but not from the same
environment
13. Improving Iteration Speed
● Per-line output
● Immediate feedback
● Breakpoints and other local
debugging tools
● Unit and Integration tests
14. Deploying Your Code
● Zip-file from S3, or manual upload
○ NOTE: zip only the source code,
not the parent folder!
● Testing upload
● Publishing
● Complex, non-intuitive
16. Deploying Lambda Code
● Initializing an action- backand action init
○ Arguments available in docs.backand.com
● Copy your Node.JS code into created
directory
● Deploy - backand action deploy
○ Arguments available in docs.backand.com
17. Calling Your Lambda
● Authentication
○ can be anonymous
○ api.backand.com/1/token
○ See docs
● cURL
curl -H "<auth header>" "https://api.backand.com/1/objects/action/<object>?name=<name>"
● JavaScript (with Backand SDK)
backand.object.action.get(...)
18. What is Backand?
● Serverless app platform
● Manages your app's database
● Manages your app's security and
authentication
● Provides custom server-side code execution
● Provides hosting options
● Provides logging, analytics, and more
19. Backand Features
● Automated REST API
● Bring your own Database
● Custom JavaScript Actions
● Server-Side Code Execution
● Batch and Bulk Processing
● Scheduled Tasks
● Automated messages
● Real-time Communications
● User and Role-based
Security
● Social Media Authentication
● GUI Schema Editor
● Custom Queries
● REST API Playground
● Sample Code Generation
● Hosting
● Detailed Analytics
● Logging
● Multi-Platform SDK
● Single Sign On Support