https://pulumi.com logo
#typescript
Title
# typescript
a

adamant-translator-31969

01/25/2021, 5:32 PM
Hi! How can I add trigger to my lambda function? more specifically a SQS trigger
b

brave-planet-10645

01/25/2021, 5:36 PM
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

bland-byte-34481

01/25/2021, 7:34 PM
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

brave-planet-10645

01/25/2021, 7:59 PM
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

bland-byte-34481

01/25/2021, 8:43 PM
thx!
a

adamant-translator-31969

01/25/2021, 9:10 PM
thaaanks!!