AWS Serverless Architecture
with Lambda

Serverless Pattern
EVENT SOURCE
FUNCTION
SERVICES

NODE
PYTHON
JAVA
C#
STATE CHANGES
- RESOURCES
- DATA
ENDPOINT REQUESTS

Anatomy of a Lambda Function
'use strict';
// imports and dependencies
exports.handler = function (event, context) {
context.done(null, "Hello World!");
};Example - s3 PUT Event Object
{
"Records": [
{
"eventVersion": "2.0",
"eventTime": "1970-01-01T00:00:00.000Z",
"requestParameters": {
"sourceIPAddress": "127.0.0.1"
},
"s3": {
"configurationId": "testConfigRule",
"object": {
"eTag": "0123456789abcdef0123456789abcdef",
"sequencer": "0A1B2C3D4E5F678901",
"key": "HappyFace.jpg",
"size": 1024
},
"bucket": {
"arn": bucketarn,
"name": "sourcebucket",
"ownerIdentity": {
"principalId": "EXAMPLE"
}
},
"s3SchemaVersion": "1.0"
},
"responseElements": {
"x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH",
"x-amz-request-id": "EXAMPLE123456789"
},
"awsRegion": "us-east-1",
"eventName": "ObjectCreated:Put",
"userIdentity": {
"principalId": "EXAMPLE"
},
"eventSource": "aws:s3"
}
]
}Lambda Benefits
- Simple Set-up
- Low Learning-curve
- Zero Administration
- Easy Monitoring
- Automatic Scaling
- Only pay for use

AutoRenter on AWS
AutoRenter Spec
Auth
API
Compute
Database
API Gateway
Lambda
DynamoDB
Cognito



Serverless Architecture (with FaaS)




Client
What type of serverless architecture?
- Nanoservices
- Microservices
- Monolith
Nanoservices

Microservices

Monolithic

npm i -g serverless
serverless create --template aws-nodejs
serverless deploy
serverless logs
serverless removeDebugging
1. CloudWatch logs in the AWS console
2. CloudWatch logs from the AWS CLI
3. Third party logging software
eg Librato
sls logs -f hello -t

Unit Testing
// Use any unit testing framework
- Zip and Upload, then Test
- Command Line
- Testing Frameworks (example)
Live Testing
CI/CD
Serverless Use Cases


Web Applications
Backends
Data Processing
Chatbots
Alexa
IT Automation
Contact
- github: gwenf
- twitter: gwen_faraday
- email: gwenfaraday@gmail.com
Links
deck
By gwenf
deck
- 551