#✅ - DLQ Lambda

4 messages · Page 1 of 1 (latest)

void field
#

How can I configure a deadletter queue for my lambda function?

I followed https://docs.amplify.aws/react/build-a-backend/add-aws-services/custom-resources/ to create an SQS queue. I followed https://docs.amplify.aws/react/build-a-backend/functions/set-up-function/ to setup my function.

Now I am trying to connect the queue ot the function in my backend.ts, but assigning is not allowed, what I am trying to do is:

lambdaStreamUsage.deadLetterQueue = sqsDeadLetterQueue;

lambdaStreamUsage i get from backend.dbStreamUsageFunction.resources.lambda as Function;

The error I get is: Cannot assign to 'deadLetterQueue' because it is a read-only property.ts(2540)

Maybe a more general question, as I ran into this now quite often: I think a lot of things in CDK are only configurable in the constructor. But amplify creates those things already, so after creation it is hard to change things like the DLQ? Am I correct? How is this supposed to work for developers like me that want to extend things? Are there any tricks?

hearty rivet
#

Have you tried something like this?

backend.dbStreamUsageFunction.resources.cfnResources.cfnFunction.deadLetterConfig = {
    targetArn: "dead_letter_queue_arn",
};
void field
#

Yes, your code works! No errors from typesript and deployment also worked fine, thanks a lot!

In the meantime I ended up doing this (which also works):

cfnLambdaStreamUsage.addPropertyOverride("DeadLetterConfig", {
TargetArn: sqsDeadLetterQueue.queueArn,
});

But i will change it to your code, ... seems better to do it without an override.

edgy geyserBOT
#

✅ - DLQ Lambda