amit
amit

Reputation: 2331

What is an elegant way to create a "logic glue" of a serverless app

I need to implement the following logic:

  1. PDF with several (unknown in advanced) pages is upload and saved to S3
  2. Page images are extracted from the pdf via a lambda function and saved to S3.
  3. Each image is analyzed by a lambda function (concurrently). The results are saved either to S3 or dynamo.
  4. Once ALL the images has been analyzed, run a final single lambda that combine all of the results.

One of my main issue is how to get triggered when all the concurrent lambdas of step 3 has finished. What is the best, most elegant way to accomplish that? I had suggestions to try using AWS step function, but it seems that the Parallel state can only have fixed number, known in advance branches.

Upvotes: 1

Views: 92

Answers (1)

Kunal Pradhan
Kunal Pradhan

Reputation: 522

As you are already using Dynamodb in your solution, one possible solution I could think:

Step 2: 
        Extract Images and store total_count in Dynamodb
Step 3: 
       At the end of Lambda increment new column current_count
       if(current_count==total_count){ trigger Step 4 }

Upvotes: 2

Related Questions