Skip to content

Instantly share code, notes, and snippets.

@SeanDrum
Last active February 1, 2021 22:44
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 SeanDrum/341e32493fe2415110a89af48e155de7 to your computer and use it in GitHub Desktop.
Save SeanDrum/341e32493fe2415110a89af48e155de7 to your computer and use it in GitHub Desktop.
Example Python Lambda Warmer
def getWidgets (event, context):
try:
if event['warmer'] == 1:
return 'warmed'
except KeyError:
pass
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Widgets')
response = table.get_item(Key={'Id': int(event['queryStringParameters']['Id'])})
widgets = response['Item']['widgets']
response = {
'statusCode': 200,
'headers': {'Access-Control-Allow-Origin': '*'},
'body': json.dumps(widgets)
}
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment