Last active
February 1, 2021 22:44
-
-
Save SeanDrum/341e32493fe2415110a89af48e155de7 to your computer and use it in GitHub Desktop.
Example Python Lambda Warmer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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