0
votes

I’ve created a Dynamodb table that will be populated with hostnames that I want to ping using AWS Lambda. Every time a new entry is added to this Dynamodb table, I want a new scheduled job to be added to a lambda function for the specified hostname. For example, if I have 100 hostnames in my dynamodb table, I would have 100 scheduled jobs at various intervals executing the lambda function. Is there a way to execute this?

1
Are you referring to scheduling lambda or triggering lambda? - helloV
@helloV scheduling lambda - Paul
Unless you want to schedule it for a particular reason, you should consider triggering it. Less work for you. - helloV

1 Answers

0
votes

AWS Lambda functions can be triggered by many different event sources, including direct invocation via an API call and also from a schedule within Amazon CloudWatch Events.

It appears that your goal is:

  • At a regular time period
  • For each entry in a given DynamoDB table
  • Execute a Lambda function

Rather than creating 100 schedules for 100 entries, you could just create a single entry:

  • When the schedule fires...
  • Run a Lambda function that reads the table
  • For each entry in the table, call a new Lambda function, passing in the desired hostname that was retrieved from the database

This way, you only require one schedule that will automatically fire off other tasks based upon the number of entries in the database table.

Please note that there is a default limit of 100 concurrent Lambda functions. So, if your function takes 0.5 seconds to run, only 200 functions would run per second.