import json
print('Loading function')
def lambda_handler(event, context):
#print("Received event: " + json.dumps(event, indent=2))
print("value1 = " + event['key1'])
print("value2 = " + event['key2'])
print("value3 = " + event['key3'])
return event['key1'] # Echo back the first key value
import json
print('Loading function')
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
response = {
'statusCode': 200,
'headers':{'x-hello-world':'some-header/value'},
'body': event['body']
}
return response # return the request body


chtompki@Robs-MacBook-Pro ~ % curl \
-X POST https://jnvg8rtlt8.execute-api.us-east-1.amazonaws.com/prod \
-d '{"key1":"value1", "key2":"value2", "key3":"value3"}' && echo ""
{"key1":"value1", "key2":"value2", "key3":"value3"}
Queue the Serverless Application Framework
serverless.ymlservice: chtompki-serverless-example-api
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: '20201221'
## IMPORTANT: Serverless makes too many buckets
deploymentBucket:
name: chtompki-serverless-deployments
serverSideEncryption: AES256
functions:
hello:
handler: lambda_function.lambda_handler
events:
- http:
path: /
method: post
sls deployWe get a cloudformation deployment looking like this


chtompki@Robs-MacBook-Pro ~ % curl \
-X POST https://cckfhngf25.execute-api.us-east-1.amazonaws.com/dev \
-d '{"key1":"value1", "key2":"value2", "key3":"value3"}' && echo ""
{"key1":"value1", "key2":"value2", "key3":"value3"}
serverless.yml can declare all parts of CFT under resources sectionplugins seciton of the serverless.yml allows importing other node modules that accommodate more customizations