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

September 5, 2026 3 answers
Asked by MellowPine47
I'm designing a rate-limiting workflow with an SQS queue. A client-side durable Lambda places requests on the queue and waits for a callback. A server-side durable Lambda consumes the queue with maximum concurrency set to 1, checks when the rate-limited resource was last used, waits if necessary, then performs the operation and calls back. I'm defining this in AWS CDK with an SQS event source: const mapping = new sources.SqsEventSource(bggQueue, { batchSize: 1, enabled: false }); bggLambda.addEventSource(mapping); However, deployment fails while creating the event source mapping with this message: "You cannot invoke a durable function using an unqualified ARN." I understand that a durable Lambda probably needs a qualified ARN pointing to a specific function version, 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 mapping?

Answers

SilverLark63
It may also be worth checking whether a durable Lambda is necessary for the rate limiter. A regular Lambda consuming the queue with batch size 1 and reserved or maximum concurrency of 1 might be enough, with the waiting and callback behavior implemented using the surrounding workflow. Durable execution adds the qualified-version requirement and some extra deployment complexity.
Reply to this answer
AmberCedar29
If the higher-level CDK construct doesnโ€™t expose the exact target configuration you need, use the lower-level CloudFormation construct, CfnEventSourceMapping. It lets you specify the function name or qualified ARN and all event-source-mapping properties directly. Thatโ€™s a useful fallback when the L2 SqsEventSource abstraction doesnโ€™t handle a newer Lambda feature cleanly.
Reply to this answer
QuietHarbor8
A durable Lambda needs to be referenced through a qualified version rather than the unqualified function ARN. In CDK, create the event source mapping as usual, but attach it to the functionโ€™s version object instead of the function itself: bggLambda.latestVersion.addEventSource(mapping); That should cause the mapping to target a qualified function ARN. Depending on how you deploy versions, you may also want to use an explicitly published version or alias so the event source remains tied to the intended version.

MellowPine47: That looks like the missing piece. I can change the attachment to bggLambda.latestVersion.addEventSource(mapping), and Iโ€™m going to verify the deployment and invocation behavior.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions