Created
February 9, 2024 15:57
-
-
Save sohalloran/87a9860ebd91ec2d5e38bed9e91a0a34 to your computer and use it in GitHub Desktop.
Webhook python service for lambda - used by the terraform script
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
from __future__ import print_function | |
from datetime import datetime | |
import boto3, os, json | |
def lambda_handler(event, context): | |
print("Received event: " + json.dumps(event, indent=2)) | |
now = datetime.now() | |
s3 = boto3.resource('s3') | |
object = s3.Object(os.environ['BUCKET_NAME'], now.strftime("%d%m%Y_%H%M%S")+'.json') | |
object.put(Body=event["body"]) | |
return { | |
"statusCode": 200, | |
"headers": { | |
"Content-Type": "text/plain" | |
}, | |
"body": '[accepted]' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment