'Is it possible to call a lambda function at the end of Textract processing

Is it possible to call a lambda function at the end of some AWS Textract processing?



Solution 1:[1]

What you can do is to put the result of the AWS Textract processing in an S3 Bucket.

And then use a S3 trigger to invoke a Lambda function - https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html

Solution 2:[2]

When you're using asynchronous StartDocumentAnalysis it's possible to give SNS notification channel as a parameter. After processing is finished, proper message will be published. Java example below. You also have to specify a proper role that will allow Textract to publish to SNS.

For synchronous processing you can trigger lambda manually.

Alternative solution would be to use S3 bucket to store result and add trigger there.

    StartDocumentAnalysisRequest documentAnalysisRequest = StartDocumentAnalysisRequest.builder()
        .documentLocation(DocumentLocation.builder()
            .s3Object(document)
            .build())
        .featureTypes(List.of(FeatureType.TABLES))
        .notificationChannel(NotificationChannel.builder()
            .snsTopicArn(snsTopic) //topic for the message
            .roleArn(role) //role with SNS publish permissions
            .build())
        .build();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BTL
Solution 2 thatninjadev