Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add EventHandler for triggering asynchronous execution #5627

Open
1 of 2 tasks
sinofseven opened this issue Nov 22, 2024 · 6 comments
Open
1 of 2 tasks
Labels

Comments

@sinofseven
Copy link

Use case

I would like to use monolithic Lambda as a mechanism to build asynchronous execution Lambda Functions.

Python Runtime's SnapStart charges a cache fee for each version of the Lambda Function.
I believe that reducing the number of Lambda Functions created by Monolithic Lambda would be a useful cost saving measure.

While it is easy to build monolithic Lambda with API Gateway's backend Lambda because of EventHandler, it is not easy to build monolithic Lambda for asynchronous Lambda execution.
I would like to create a new EventHandler to facilitate this.

Solution/User Experience

app = AsynchronousTriggerResolver()


@app.sns("<String to identify>")
def process_sns_01():
    pass


@app.sns("<String to identify>")
def process_sns_02():
    pass


@app.event_bridge("<String to identify>")
def process_event_bridge():
    pass


@app.cloudwatch_logs("<String to identify>")
def process_cloudwatch_logs():
    pass


def lambda_handler(event, context):
    return app.resolve(event, context)

I am thinking that it would be good if we could use it like an EventHandler for API Gateway.

Alternative solutions

Acknowledgment

@sinofseven sinofseven added feature-request feature request triage Pending triage from maintainers labels Nov 22, 2024
Copy link

boring-cyborg bot commented Nov 22, 2024

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@leandrodamascena
Copy link
Contributor

Hi @sinofseven Sorry for the super super late reply, but things are a bit slower at the end of the year because we are presenting at re:Invent, we need to deal with some internal stuff and most people are going on annual leave.

Regarding this issue, I can say that I really like the idea and we are discussing it in our roadmap for 2025. This could be a generic event handler for many services: S3, StepFunctions, EventBridge, SQS, SNS and we can decide which part of the event we can use as a route, regular expressions, part of the string, many possibilities. This will make life easier for people who are dealing with EventBridge for example and want to use a single Lambda for some events. I see a lot of benefits in this new utility and it would be cool to release it in 2025.

Do you want to create an RFC for this? Ideas? Prototyping?

@leandrodamascena leandrodamascena added event_handlers and removed triage Pending triage from maintainers labels Dec 23, 2024
@leandrodamascena
Copy link
Contributor

Sorry, I pressed enter before complete the message.

We can work together on this RFC. We are really thinking about this utility in 2025.

@sinofseven
Copy link
Author

sinofseven commented Dec 24, 2024

@leandrodamascena

Thank you, your reply.

Do you want to create an RFC for this? Ideas? Prototyping?

Currently, I have only ideas.

I was waiting for it to be triaged according to “Contributing via Pull Requests” in CONTRIBUTION.md.

Now that it has been triaged, I am thinking of implementing a prototype.

My idea is to create an EventHandler for asynchronous Lambda triggers.

Since the current EventHandler is divided into one for REST API, one for HTTP API, and one for AppSync, I think it would be better to create an EventHandler for each type of Lambda execution (synchronous, asynchronous, event source mapping). I think it would be a good idea.
(For synchronous execution, I think it would be better to create one for each service such as API Gateway, AppSync, StepFunctions, Cognito, etc.)
(For event source mapping, I am wondering if it is better to use EventHandler for Lambda for asynchronous execution, or if I should create a separate EventHandler.)

@sinofseven
Copy link
Author

In addition, the prototype implementation assumes asynchronous Lambda event sources whose types are defined in data_classes.

@sinofseven
Copy link
Author

sinofseven commented Dec 27, 2024

I have not yet confirmed operation, created tests, or written comments, but I have implemented the system and created a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants