How do I attach an SQS event source to a versioned durable Lambda in CDK?

0
0
Asked By MellowPine42 On

I'm designing a rate-limiting workflow with an SQS queue. A client durable Lambda places a request on the queue and waits for a callback. A server durable Lambda consumes the queue with maximum concurrency set to 1, checks when the rate-limited resource was last used, waits if necessary, and then performs the operation before invoking the callback.

I'm defining this with the AWS CDK. The following setup worked previously for a regular Lambda consuming SQS:

const mapping = new sources.SqsEventSource(bggQueue, { batchSize: 1, enabled: false });
bggLambda.addEventSource(mapping);

However, creating the event source mapping fails with an error saying that a durable function cannot be invoked using an unqualified ARN. I understand that durable functions require a specific qualified version or alias, but I'm not sure how to express that through the CDK Function object. What is the correct way to attach the SQS event source to the durable Lambda?

2 Answers

Answered By RiverNook18 On

If the higher-level CDK construct does not expose everything you need, use the L1 `CfnEventSourceMapping` resource. It lets you provide the event source ARN and a qualified function ARN explicitly. For this case, though, using a published version or alias through the Function object should normally be enough.

Answered By QuietMarble5 On

Double-check whether a durable Lambda is necessary for the rate limiter. An SQS consumer with reserved or maximum concurrency of one, combined with visibility timeout and retry handling, may be sufficient depending on how long the wait and callback workflow lasts. If the function genuinely needs durable execution semantics, make sure the event source targets a qualified version or alias.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.