Serverless Architectures

A Practical Introduction - Dan Lindeman
@lindemda


<-You
Code goes ->
Who am I?




Real serverless apps!

-
The Lady of the Lake -
Search Backends
-
AirBnB-like Backend
-
Data Ingestion Pipelines
Charter
- Motivations
- Traditional
- Serverless
- Tradeoffs


Definition of Terms
- serverless vs. Serverless™
- Thing or Service -> AWS
One Constant




A natural evolution




You're also "Lightly Op'd"

I don't know


I don't know

I don't know

I don't know

https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html

are we making so many



Main Event

Meet Serverless™

https://serverless.com/framework/docs/getting-started/
The Promise



A note about vendor lock-in
- Lambda is hardly to blame
- Dynamo, SNS, and S3 are.

Two Scoops of Django Flask

Our favorites
data = {
"dan": "mint chocolate chip",
"bill": "mint chocolate chip",
"marija": "mint chocolate chip",
"liz": "pistachio",
"shane": "rocky road",
"andy": "cookie dough",
"cedric": "cookie dough",
"eileen": "cookie dough",
}
API
GET /team
{
"andy": "cookie dough",
"bill": "mint chocolate chip",
"cedric": "cookie dough",
"dan": "mint chocolate chip",
"eileen": "cookie dough",
"liz": "pistachio",
"marija": "mint chocolate chip",
"shane": "rocky road"
}
GET /ice-cream/<person>
{"cookie dough"}

@app.route("/team/")
@jwt_required
def team():
...
@app.route("/ice-cream/<person>")
@jwt_required
def lookup(person):
...
def authenticate(username, password):
...
def identity(payload):
...
app = Flask(__name__)
app.debug = True
app.config['SECRET_KEY'] = 'super-secret'
jwt = JWT(app, authenticate, identity)
Now what?
- Provision a server?
- Deploy the code?


Two Scoops of Django Serverless

service: flavorless
provider:
name: aws
runtime: python3.6




plugins:
- serverless-python-requirements
- serverless-kms-secrets
custom:
pythonRequirements:
dockerizePip: non-linux
functions:
team:
handler: handler.team
events:
- http:
path: /team
method: get
@app.route("/team/")
def team():
...




lookup:
handler: handler.lookup
events:
- http:
path: /ice-cream/{person}
method: get
request:
parameters:
paths:
person: true
@app.route("/ice-cream/<person>")
def lookup(person):
...


def authenticate(username, password):
def identity(payload):
app = Flask(__name__)
jwt = JWT(app, authenticate, identity)
authorizer:
handler: handler.authorize
environment:
TOKEN_ISSUER: ...
AUDIENCE: ...
JWKS_URI: ...
lookup:
handler: handler.lookup
events:
- http:
path: /ice-cream/{person}
method: get
request:
parameters:
paths:
person: true
authorizer:
name: authorizer
identityValidationExpression: ^Bearer [-0-9a-zA-z\.]*$
def team(event, context):
...
def lookup(event, context):
...
def authorize(event, context):
...
handler.py
403 Hell


https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
Now what?
- sls deploy
Tour of AWS post-deploy


Logs

Resources

Side note

What does that get us?






Selfishly

Not-so-great




Never would I ever
https://serverless.com/blog/when-why-not-use-serverless/
Cool highlights and Pro Tips

Service Shoutouts


resources:
- ${file(../resources/dynamodb.yml)}
- ${file(../resources/gateway.yml)}

Locally sourced tests

Recap
- Are there servers?
- A silver bullet?
- Reasons to adopt?
- Functional
- Non-functional
- Reasons to not

Getting Started
- https://serverless-stack.com/
- https://acloud.guru/
Thank you so very much.

Serverless
By dlindema
Serverless
A talk about the serverless framework, with a toy example comparing it to a small web framework like Flask
- 742