This commit is contained in:
2
shuffle/functions/extensions/aws-s3-lambda/README.md
Normal file
2
shuffle/functions/extensions/aws-s3-lambda/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# AWS Lambda forwarder to Shuffle
|
||||
This function is made to forward S3 notifications to Shuffle to run a workflow when an object is made or updated.
|
22
shuffle/functions/extensions/aws-s3-lambda/s3_function.py
Normal file
22
shuffle/functions/extensions/aws-s3-lambda/s3_function.py
Normal file
@ -0,0 +1,22 @@
|
||||
import json
|
||||
import urllib.parse
|
||||
import urllib3
|
||||
import os
|
||||
|
||||
print('Loading function')
|
||||
|
||||
def lambda_handler(event, context):
|
||||
# Get the object from the event and show its content type
|
||||
bucket = event['Records'][0]['s3']['bucket']['name']
|
||||
|
||||
webhook = os.environ.get("SHUFFLE_WEBHOOK")
|
||||
if not webhook:
|
||||
return "No webhook environment defined: SHUFFLE_WEBHOOK"
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
ret = http.request('POST', webhook, body=json.dumps(event["Records"][0]).encode("utf-8"))
|
||||
if ret.status != 200:
|
||||
return "Bad status code for webhook: %d" % ret.status
|
||||
|
||||
print("Status code: %d\nData: %s" % (ret.status, ret.data))
|
||||
return "Successfully started with data %s" % ret.data
|
Reference in New Issue
Block a user