Skip to content

Instantly share code, notes, and snippets.

@sohalloran
Created February 9, 2024 15:57
Show Gist options
  • Save sohalloran/87a9860ebd91ec2d5e38bed9e91a0a34 to your computer and use it in GitHub Desktop.
Save sohalloran/87a9860ebd91ec2d5e38bed9e91a0a34 to your computer and use it in GitHub Desktop.
Webhook python service for lambda - used by the terraform script
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