mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 15:26:17 +00:00
3f6077eb18
Attempting to do some log parsing into cloudwatch logs
19 lines
575 B
JavaScript
19 lines
575 B
JavaScript
const { parseLogFile } = require('./cloudfront');
|
|
const { putLogEvents } = require('./cloudwatch-logs');
|
|
|
|
// Lambda handler.
|
|
//
|
|
exports.handler = async (event) => {
|
|
if (event.Records.length !== 1) {
|
|
throw new Error(`Wrong length of events.Records, expected: '1', got: '${event.Records.length}'`);
|
|
} else {
|
|
const params = {
|
|
bucket: event.Records[0].s3.bucket.name,
|
|
key: decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' ')),
|
|
region: event.Records[0].awsRegion,
|
|
};
|
|
|
|
return putLogEvents(await parseLogFile(params));
|
|
}
|
|
};
|