One Lambda, two services?

0

Can I have the same Lambda working as a REST service under API GW, and also consuming CloudWatch events? Or I need two separate? They would do exactly the same so I thought I could have the same JAR (I'm in Java) registered by both services, but I can't do it and don't know is it by design or I'm messing it up...
Thank you!

soco
질문됨 4년 전2199회 조회
3개 답변
0
수락된 답변

There can't be two entry points. A single lambda has a single handler function, which would need to separate out the different event types.

Ellison
답변함 4년 전
0

It's certainly possible to register multiple triggers for a single lambda. We'd need to know the steps you're taking and the errors you're seeing to say more about what's going wrong in your case.

However, multiple triggers make things complicated, since you need to add logic for determining what kind of event you were invoked with, and then handle the different event formats before invoking the common code. It might be better to have two different lambdas to handle the different triggers. You might either include the common code in both deployment zips, or factor it into a layer.

Ellison
답변함 4년 전
0

I was thinking to have the same code acting as a REST service behind the API gateway, and also handle CloudWatch scheduled events. Thus there would be two entry points, no need to differentiate between inputs.

The errors I receive are from the Quarkus framework which won't support my idea, so I was curios whether it's a Lambda principle or a Quarkus limitation. I'll go anyway with two lambdas as you suggested but I'd like to understand the principle behind...

soco
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠