Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// S3 Event processor
const s3Processor = new lambda.Function(this, 'S3Processor', {
runtime: lambda.Runtime.Python37,
code: lambda.Code.asset('lambda/s3processor'),
handler: 'lambda_function.lambda_handler',
environment: {
SYNC_QUEUE_URL: syncJobsQueue.queueUrl,
ASYNC_QUEUE_URL: asyncJobsQueue.queueUrl,
DOCUMENTS_TABLE: documentsTable.tableName,
OUTPUT_TABLE: outputTable.tableName
}
});
//Layer
s3Processor.addLayer(helperLayer)
//Trigger
s3Processor.addEventSource(new S3EventSource(contentBucket, {
events: [ s3.EventType.ObjectCreated ]
}));
//Permissions
documentsTable.grantReadWriteData(s3Processor)
syncJobsQueue.grantSendMessages(s3Processor)
asyncJobsQueue.grantSendMessages(s3Processor)
//------------------------------------------------------------
// S3 Batch Operations Event processor
const s3BatchProcessor = new lambda.Function(this, 'S3BatchProcessor', {
runtime: lambda.Runtime.Python37,
code: lambda.Code.asset('lambda/s3batchprocessor'),
handler: 'lambda_function.lambda_handler',
environment: {
DOCUMENTS_TABLE: documentsTable.tableName,
SUPPORTED_AUDIO_SUFFIX.forEach(suffix => {
this.addAudioFunc.addEventSource(
new S3EventSource(props.audioFileBucket, {
events: [s3.EventType.OBJECT_CREATED],
filters: [{ suffix }],
})
);
});