Skip to content

Commit

Permalink
change upload function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel committed Jul 21, 2020
1 parent cbe0a53 commit 2b083bc
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lambda/ingest-urlscan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import boto3
import botocore
import json

logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
Expand Down Expand Up @@ -41,20 +42,12 @@ def main(event, context):
found = True

if not found:
create_key(bucket_name, site)

logging.info("\tBloopy bloop.")

def create_key(bucket, key):
logging.info(f"Creating key {key} in bucket {bucket}.\n")
s3 = boto3.client('s3')
try:
s3.put_object(Bucket=bucket, Key=key)
except botocore.exceptions.ClientError as e:
logging.error(e)
return False
return True
upload(bucket_name, site)

def upload(topic_arn,site):
logging.info(f"Publishing {site} to SNS topic.\n")
client = boto3.client('sns')
client.publish(TargetArn=topic_arn, Message=json.dumps({'bucket': site}), Subject=f"New site to check",MessageStructure='json')

if __name__ == "__main__":
main(None, None)

0 comments on commit 2b083bc

Please sign in to comment.