Hi! How can I add trigger to my lambda function? ...
# typescript
a
Hi! How can I add trigger to my lambda function? more specifically a SQS trigger
b
The tl;dr is that you create an SQS resource and then you register the onEvent for that resource. There's an S3 example here. If you swap out S3 for SQS that should work
There are a few ways you can write lambdas. The easiest is using what we call a "magic lambda function" where you just write the code and it looks something like this:
Copy code
import * as aws from "@pulumi/aws";

const queue = new aws.sqs.Queue("my-queue");

queue.onEvent("handler", (e) => {
    console.log(e);
});
That link above will show you other ways you can write lambdas, some (like my example) you don't get many config options (like memory) but scroll down and there are some good examples there
b
I have the same question as Mati... there is TONS of documentation on how to create functions that RESPOND to events but not how to CREATE an event that will actually trigger the thing
or maybe that's not Mati's question 🙂
b
That's not really what pulumi does. That's a job for the AWS SDK. There are some docs here https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/sqs-examples-send-receive-messages.html
b
thx!
a
thaaanks!!