https://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html
https://serverless.com/framework/docs/getting-started/
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",
}
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)
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):
...
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
resources:
- ${file(../resources/dynamodb.yml)}
- ${file(../resources/gateway.yml)}