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

Document how to use SQS to trigger Lambda #421

Closed
mnapoli opened this issue Aug 21, 2019 · 4 comments
Closed

Document how to use SQS to trigger Lambda #421

mnapoli opened this issue Aug 21, 2019 · 4 comments

Comments

@mnapoli
Copy link
Member

mnapoli commented Aug 21, 2019

This topic has been brought up multiple times and I realized that we have no "official" issue for this.

Here is a good article that will help cover the details in the documentation article to create: https://lumigo.io/blog/sqs-and-lambda-the-missing-guide-on-failure-modes/

@victormacko
Copy link
Contributor

This might help; https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
I've done it with Symfony and it's pretty straight-forward ... is anyone working on this page already, or do you need a hand with it?

@mnapoli
Copy link
Member Author

mnapoli commented Sep 13, 2019

@victormacko I'm working on integrating Symfony Messenger. I'm interested, did you use Messenger or no library?

@victormacko
Copy link
Contributor

Yes, i've used messenger, with the following packages to get SNS happening;

  • enqueue/sns
  • sroze/messenger-enqueue-transport
    (can't remember if there's anything different needed for SQS ... prob just a different pkg if anything)

The changes between SNS and SQS are pretty minimal for receiving messages -- just the 'bin/consume' handler needs to be able to adjusted for the different JSON structure.

There's a good article on it here which I followed; http://developer.happyr.com/symfony-messenger-on-aws-lambda

I think in theory you could get away with the extra packages if you only wanted lambda to 'receive' SQS/SNS rather than using $messenger->dispatch to add back to SNS/SQS.

In terms of hooking lambda to SQS, you just need to give the lambda function some extra permissions, and setup the trigger on the SQS queue ... there's more details here which i've followed for SQS;
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

It's worth mentioning that setting up a dead-letter-queue is a good idea too -- if the lambda PHP fn throws and error, the queue will automatically re-try sending it to lambda until you remove the trigger... a friend's already gotten a nasty surprise in the form of a big bill $$ from that mistake!

@mnapoli
Copy link
Member Author

mnapoli commented Nov 21, 2020

I've improved the documentation in 1.0 with a short example. There's also https://serverless-visually-explained.com/ that includes more complete examples.

@mnapoli mnapoli closed this as completed Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants