How to use the @aws-cdk/aws-lambda-event-sources.SqsEventSource function in @aws-cdk/aws-lambda-event-sources

To help you get started, we’ve selected a few @aws-cdk/aws-lambda-event-sources examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phstc / shoryuken-serverless / bin / shoryuken-serverless.ts View on Github external
runtime: new lambda.Runtime('ruby2.5'),
      handler: 'lambda.handler',
      code: lambda.Code.asset('./rails_sample_app'),
      timeout: 60,
      environment: {
        QUEUE_STANDARD: queueStandardWorkers.queueName,
        QUEUE_ACTIVEJOB: queueActiveJob.queueName,
        RAILS_ENV: 'production'
      }
    })

    queueActiveJob.grantSendMessages(fn.role)

    // batchSize defaults to 10, if you use > 1, your Lambda needs to be able to process in parallel,
    // otherwise, if your messages take 1 minute to be processed, the last one will take up to 10 minutes to start being processed
    fn.addEventSource(new SqsEventSource(queueStandardWorkers, { batchSize: 1 }))
    fn.addEventSource(new SqsEventSource(queueActiveJob, { batchSize: 1 }))
  }
}
github phstc / shoryuken-serverless / bin / shoryuken-serverless.ts View on Github external
handler: 'lambda.handler',
      code: lambda.Code.asset('./rails_sample_app'),
      timeout: 60,
      environment: {
        QUEUE_STANDARD: queueStandardWorkers.queueName,
        QUEUE_ACTIVEJOB: queueActiveJob.queueName,
        RAILS_ENV: 'production'
      }
    })

    queueActiveJob.grantSendMessages(fn.role)

    // batchSize defaults to 10, if you use > 1, your Lambda needs to be able to process in parallel,
    // otherwise, if your messages take 1 minute to be processed, the last one will take up to 10 minutes to start being processed
    fn.addEventSource(new SqsEventSource(queueStandardWorkers, { batchSize: 1 }))
    fn.addEventSource(new SqsEventSource(queueActiveJob, { batchSize: 1 }))
  }
}
github aws-samples / amazon-textract-serverless-large-scale-document-processing / textract-pipeline / lib / textract-pipeline-stack.ts View on Github external
runtime: lambda.Runtime.Python37,
      code: lambda.Code.asset('lambda/syncprocessor'),
      handler: 'lambda_function.lambda_handler',
      reservedConcurrentExecutions: 1,
      timeout: 25,
      environment: {
        OUTPUT_TABLE: outputTable.tableName,
        DOCUMENTS_TABLE: documentsTable.tableName,
        AWS_DATA_PATH : "models"
      }
    });
    //Layer
    syncProcessor.addLayer(helperLayer)
    syncProcessor.addLayer(textractorLayer)
    //Trigger
    syncProcessor.addEventSource(new SqsEventSource(syncJobsQueue, {
      batchSize: 1
    }));
    //Permissions
    contentBucket.grantReadWrite(syncProcessor)
    existingContentBucket.grantReadWrite(syncProcessor)
    outputTable.grantReadWriteData(syncProcessor)
    documentsTable.grantReadWriteData(syncProcessor)
    syncProcessor.addToRolePolicy(new iam.PolicyStatement().addAllResources().addActions("textract:*"))

    //------------------------------------------------------------

    // Async Job Processor (Start jobs using Async APIs)
    const asyncProcessor = new lambda.Function(this, 'ASyncProcessor', {
      runtime: lambda.Runtime.Python37,
      code: lambda.Code.asset('lambda/asyncprocessor'),
      handler: 'lambda_function.lambda_handler',
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
// Lambda Functions
    const baseEnvVars = {
      TASK_TOPIC: this.taskTopic.topicArn,
      REPORT_TOPIC: this.reportTopic.topicArn,
      CACHE_TABLE: this.cacheTable.tableName,
    };
    const nodeModulesLayer = new lambda.LayerVersion(this, "NodeModulesLayer", {
      code: lambda.AssetCode.fromAsset("????"),
      compatibleRuntimes: [lambda.Runtime.NODEJS_10_X],
    });
    this.recvAlert = new NodejsFunction(this, "recvAlert", {
      entry: path.join(__dirname, "lambda/recvAlert.js"),
      handler: "main",
      timeout: alertQueueTimeout,
      role: lambdaRole,
      events: [new SqsEventSource(this.alertQueue)],
      environment: Object.assign(baseEnvVars, {
        INSPECTOR_MACHINE: "",
        REVIEW_MACHINE: "",
      }),
    });

    this.submitContent = new NodejsFunction(this, "submitContent", {
      entry: path.join(__dirname, "lambda/submitContent.js"),
      handler: "main",
      role: lambdaRole,
      events: [new SqsEventSource(this.alertQueue)],
      environment: baseEnvVars,
    });

    this.feedbackAttribute = new NodejsFunction(this, "feedbackAttribute", {
      entry: path.join(__dirname, "lambda/feedbackAttribute.js"),
github aws-samples / amazon-textract-serverless-large-scale-document-processing / textract-pipeline / lib / textract-pipeline-stack.ts View on Github external
code: lambda.Code.asset('lambda/jobresultprocessor'),
      handler: 'lambda_function.lambda_handler',
      memorySize: 2000,
      reservedConcurrentExecutions: 50,
      timeout: 900,
      environment: {
        OUTPUT_TABLE: outputTable.tableName,
        DOCUMENTS_TABLE: documentsTable.tableName,
        AWS_DATA_PATH : "models"
      }
    });
    //Layer
    jobResultProcessor.addLayer(helperLayer)
    jobResultProcessor.addLayer(textractorLayer)
    //Triggers
    jobResultProcessor.addEventSource(new SqsEventSource(jobResultsQueue, {
      batchSize: 1
    }));
    //Permissions
    outputTable.grantReadWriteData(jobResultProcessor)
    documentsTable.grantReadWriteData(jobResultProcessor)
    contentBucket.grantReadWrite(jobResultProcessor)
    existingContentBucket.grantReadWrite(jobResultProcessor)
    jobResultProcessor.addToRolePolicy(new iam.PolicyStatement().addAllResources().addAction("textract:*"))
  }
}
github deepalert / deepalert / lib / deepalert-stack.ts View on Github external
});

    this.submitContent = new NodejsFunction(this, "submitContent", {
      entry: path.join(__dirname, "lambda/submitContent.js"),
      handler: "main",
      role: lambdaRole,
      events: [new SqsEventSource(this.alertQueue)],
      environment: baseEnvVars,
    });

    this.feedbackAttribute = new NodejsFunction(this, "feedbackAttribute", {
      entry: path.join(__dirname, "lambda/feedbackAttribute.js"),
      handler: "main",
      timeout: attributeQueueTimeout,
      role: lambdaRole,
      events: [new SqsEventSource(this.attributeQueue)],
      environment: baseEnvVars,
    });

    this.dispatchInspection = new NodejsFunction(this, "dispatchInspection", {
      entry: path.join(__dirname, "lambda/dispatchInspection.js"),
      handler: "main",
      role: lambdaRole,
      environment: baseEnvVars,
    });
    this.compileReport = new NodejsFunction(this, "compileReport", {
      entry: path.join(__dirname, "lambda/compileReport.js"),
      handler: "main",
      role: lambdaRole,
      environment: baseEnvVars,
    });
    this.dummyReviewer = new NodejsFunction(this, "dummyReviewer", {

@aws-cdk/aws-lambda-event-sources

Event sources for AWS Lambda

Apache-2.0
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis