My team and I are working on a Full-Stack Application using ReactJS on the frontend and AWS Amplify on the backend. We are using AWS AppSync to Query data in our DynamoDB tables (through GraphQL Queries), Cognito for User Authentication, and SES to send out emails to users. Basically, the user inputs some info (DynamoDB Table #1), and that is matched against an opportunity database (DynamoDB table #2), and the top 3 opportunities are shown to the user. If none are found, an email is sent to inform the user that they will receive an email when opportunities are found. Now for the Question: I wanted to know if there is a way to automatically Query a DynamoDB table (Like once a day or every time a new opportunity is added to the DynamoDB Table #2) and send out emails with matching opportunities to users who were waiting for them? I tried using Lambda Triggers but the only way I could do it was by querying each row of DynamoDB Table #1 against DynamoDB Table #2. That is computationally infeasible as there will be too many resources being used up. I am asking for advice on how I can go about making that daily check because I haven't been able to figure it out yet! Any responses are appreciated, and let me know if you need any additional information from my side! Thank you!
Asked
Active
Viewed 93 times
1 Answers
0
You could look into using DynamoDB Streams. When a new Opportunity is added to DynamoDB, the stream would trigger a lambda to be called. Your lambda could then execute your business logic to match the opportunity with the appropriate user.

Seth Geoghegan
- 5,372
- 2
- 8
- 23
-
Hello Seth! I did think of that, but wouldn't that mean I have to check each user from table 1 across all the rows in table 2? How is that reducing the backend work? Or is this the only way to go about doing such a thing? Is it feasible if there are 1000 users and 500 opportunities? because there will be 1000*500 checks every time there's a new insertion into the opportunity database – Anjali_Iyer Oct 08 '20 at 16:04
-
It sounds like your question has two parts. Part 1 relates to how to take action when an event occurs (e.g. new opportunity). Part 2 relates to matching users to opportunities. It sounds like you have some ideas on Part 1 (e.g. DDB Streams), but are still working out how to match users to opportunities in a performant way. Perhaps you could give more insight into your data model and how you are matching opportunities to users, since that part seems like the bottleneck for you at this point. – Seth Geoghegan Oct 08 '20 at 16:19