Hi, I'd like to build a event driven application u...
# help
r
Hi, I'd like to build a event driven application using Lambda's and Event Bridge. Upload Lambda functions that listen and pull events (messages) off Event Bridge, do some work, then put new events back onto Event Bridge. Is SST the right fit for this? The docs describe API, Auth, Storage, Database, Frontend, Cron - but I don't see just a plain old Lambda that can read/write msgs from Event Bridge.
s
Hey Rudi, SST would be great for this! As a matter of fact, there is a tutorial for using EventBridge and Lambda. Checking out the example code is pretty straightforward:
Copy code
$ npm init serverless-stack --example eventbus
# Or with Yarn
$ yarn create serverless-stack --example eventbus
SST uses the Function construct to refer to an AWS Lambda Function.
r
Ah nice, got it! Thank you very much, exactly what I was looking for.
I also can use Function for some adhoc code .. that I trigger/call manually. Manually I use the 'aws lambda invoke --cli-binary-format raw-in-base64-out --function-name .... --payload ....'
s
Exactly!
SST uses names that tend to be generic and describe the use of the construct in your application, versus the name of the AWS Service underneath. Queue instead of SQS, Topic instead of SNS, Table instead of DynamoDB, etc
o
Most of our app is built like this (apart from APIs). Some other things to consider: • Put an SQS queue in between EventBridge and lambda - you can have an EB rule with SQS as a target. It adds the ability to batch process, retries and DLQs • Have your DB publish events to EventBridge • Use EventBridge to communicate between services/pipelines, and SQS or StepFunctions to orchestrate within a service/pipeline
r
@Omi Chowdhury The SQS queue addition is interesting. I'm just exploring so I'll start with 100% EB (demo follow along), then add the SQS on after - learn by doing.
t
just an fyi we do have an eventbridge construct
also recently posted a tip about putting a queue in between EB and lambda: https://twitter.com/thdxr/status/1512423634362535944
r
@thdxr Hmm, so something like the Lambda pulls the message from the queue - but if it fails it won't confirm the msg is processed back to SQS, thus the message is still on the queue ?
t
Yeah and you can set some configuraiton on the queue to configure how long it stays there + sending it to a dead letter queue after some time
few other options as well
r
Use this strategy for both "normal" lambdas and also step functions (multi lambda) ?
t
With step functions you can create your own retry logic within the state machine so maybe less important there
there's probably some cost considerations if you're interested in absolute efficiency