Skip to content

Instantly share code, notes, and snippets.

@brevityinmotion
brevityinmotion / brevity-lambda-S3.py
Created June 9, 2021 03:42
Code example for Lambda processing a S3 trigger
def lambda_handler(event, context):
# The filename is in the format of brevityinmotion-domains-roots.csv
key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8')
fileName = os.path.basename(key)
programName = re.search("^[^-]*[^-]", fileName)
programName = programName.group(0)
@brevityinmotion
brevityinmotion / brevity-lambda-post.py
Created June 9, 2021 03:41
Code example of a Lambda processing a POST request
def lambda_handler(event, context):
eventinput = json.loads(event['body'])
if eventinput['program'] is None:
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})}
programName = str(eventinput['program'])
listscopein = list(eventinput['scopein'])
listscopeout = list(eventinput['scopeout'])
programPlatform = str(eventinput['platform'])
inviteType = str(eventinput['invite'])
@brevityinmotion
brevityinmotion / brevity-program-load.json
Created June 9, 2021 03:32
API post body for loading new programs
{
"program": "brevityinmotion",
"scopein": [
"*.brevityinmotion.com",
"securitymarker.io"
],
"scopeout": [
"icicles.io"
],
"platform": "External",