Created
May 28, 2019 11:39
-
-
Save bahrmichael/57a60c91e637c55364ea132c47e8cca3 to your computer and use it in GitHub Desktop.
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
import boto3 | |
import time | |
from uuid import uuid4 | |
# keep the db initialization outside of the functions to maintain them as long as the container lives | |
dynamodb = boto3.resource('dynamodb', region_name='us-east-1') | |
scheduling_table = dynamodb.Table('lambda-scheduling') | |
def delay(): | |
return 10 | |
def handle(payload, context): | |
print(payload) | |
id = str(uuid4()) | |
ttl = int(time.time()) + delay() | |
item = { | |
'id': id, | |
'ttl': ttl, | |
'payload': payload | |
} | |
scheduling_table.put_item(Item=item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment