Skip to content

Instantly share code, notes, and snippets.

@palanglung
Created December 6, 2018 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palanglung/0c50dae6d03e1b9f6b795db837b600cc to your computer and use it in GitHub Desktop.
Save palanglung/0c50dae6d03e1b9f6b795db837b600cc to your computer and use it in GitHub Desktop.
Sample Python 3.7 AWS Lambda SAM template.
import json
def handler(event, context):
body = {
"message": "World",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response
# Use this code if you don't use the http event with the LAMBDA-PROXY
# integration
"""
return {
"message": "Go Serverless v1.0! Your function executed successfully!",
"event": event
}
"""
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >-
Image Processor with SAM and AWS Lambda
Resources:
ImageProcessorHello:
Type: 'AWS::Serverless::Function'
Properties:
Handler: world.handler
Runtime: python3.7
CodeUri: hello
Description: >-
Trying AWS Lambda for the first time
MemorySize: 128
Timeout: 3
Events:
http:
Type: Api
Properties:
Path: /hello
Method: GET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment