def handler()

in functions/source/lifecycle-events-mapping-updater/handler.py [0:0]


def handler(event, context):
    s3_client = boto3.client('s3', region_name=os.environ.get("AWS_REGION"))

    for record in event['Records']:
        bucket = record['s3']['bucket']['name']
        key = unquote_plus(record['s3']['object']['key'])
        tmpkey = key.replace('/', '')
        download_path = '/tmp/{}{}'.format(uuid.uuid4(), tmpkey)
        s3_client.download_file(bucket, key, download_path)

        with open(download_path) as json_file:
            data = json.load(json_file)
            save_mappings(data)