Skip to content

Instantly share code, notes, and snippets.

@ryosms
Last active September 13, 2017 08:09
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 ryosms/3f3f466f9f663f5fa911a3275be69f38 to your computer and use it in GitHub Desktop.
Save ryosms/3f3f466f9f663f5fa911a3275be69f38 to your computer and use it in GitHub Desktop.
AWS SAM Local
import os
from logging import getLogger, DEBUG, INFO
logger = getLogger(__name__)
if os.getenv("AWS_SAM_LOCAL"):
logger.setLevel(DEBUG)
else:
logger.setLevel(INFO)
def lambda_handler(event, context):
logger.debug(event['requestContext']['identity']['sourceIp'])
return {'statusCode': 200}
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
SourceIpSample:
Type: "AWS::Serverless::Function"
Properties:
Runtime: python3.6
Handler: lambda_function.lambda_handler
Events:
WebHook:
Type: Api
Properties:
Path: /
Method: any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment