aws-amplify / aws-amplify/amplify-cli

One lambda to handle all cron events or one lambda per cron event?

Open
#8,034 1 comment 0 reactions 1 assignee Claimed by @renebrandel View on GitHub
feature-request functions p4
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Is this related to a new or existing Amplify category?

function

### Is this related to another service?

Lambda, Eventbridge

### Describe the feature you'd like to request

One lambda should be able to handle multiple recurring events with different schedules.

### Describe the solution you'd like

Instead of having 1:1 relationship between EventBridge and Lambda for recurring tasks, it might make sense to have a many to 1 relationship.

I could have mutliple cron jobs with different recurring schedules, but I only want one Lambda to handle all these cronjobs.

Maybe I want something that runs every hour, and another thing that runs every day.

Currently amplify cli assumes you can have only one recurring schedule per Lambda.

There is overhead in setting up each Lambda - adding IAM permissions for services that amplify cli does not support (e.g. SecretsManager) to setting up Cloudwatch alarms on the Lambda in prod. So we don't want to have too many Lambdas. We just want one Lambda to handle all recurring tasks.

I see this is supported by AWS - you can have multiple EventBridge rules hitting a lambda. You can also specify rule name in Eventbridge, and the lambda can use rule name to understand which tasks needs to be run.

This is similar to a Lambda graphql resolver, where the Lambda can handle all ```@function``` graphql resolvers, and the Lambda internally looks at the event details and routes to the right code block to execute accordingly.

We should have something similar with recurring tasks.

### Describe alternatives you've considered

- Setting up additional event bridge tasks manually
- Following amplify's cli of 1 recurring schedule per lambda

### Additional context

_No response_

### Is this something that you'd be interested in working on?

- [ ] 👋 I may be able to implement this feature request
- [ ] ⚠️ This feature might incur a breaking change

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.