Catch a Failing Lambda Pipeline Before It Eats the Queue
Put a sane failure path around an SQS-to-Lambda pipeline: retries, a dead-letter queue, alarms, and least-privilege permissions so bad messages get captured instead of silently draining morale.
#serverless#observability#iam
LabReceiptHeap, a receipt-parsing SaaS that retries failed invoices forever because "eventual consistency" got translated into "eventual landfill."all labs
02 - Actions
score -- - -- votes
-- completed
Sign in with a real account to save ratings, completions, and share snapshots.
Stateloading
03 - Scenario
ReceiptHeap, a receipt-parsing SaaS that retries failed invoices forever because "eventual consistency" got translated into "eventual landfill."
Put a sane failure path around an SQS-to-Lambda pipeline: retries, a dead-letter queue, alarms, and least-privilege permissions so bad messages get captured instead of silently draining morale.
Constraints
Failed messages must land in a dead-letter queue after a bounded number of receives
An alarm must fire when the dead-letter queue has visible messages
Lambda can read only the source queue and write only the logs it needs
Everything is Terraform and can be destroyed without leaving queues behind
ScenarioAWS - beginner
05 - Steps
STEP_01
Create the source queue and dead-letter queue
Create two SQS queues: one for incoming receipts and one dead-letter queue for messages that fail repeatedly. Configure the source queue redrive policy so poison messages move after a small, explicit receive count.
Hint: Set maxReceiveCount low during the lab so you can trigger the DLQ without waiting around like a cursed cron job.
Deploy a Lambda function and connect the source queue with an event source mapping. Set the batch size small enough that one busted receipt does not hide a whole pile of good work.
Create an execution role and policy that allows only the source queue receive/delete actions and basic log writes. Do not hand the function a project-wide "fix it in prod" sledgehammer.
Add a CloudWatch metric alarm on the dead-letter queue's visible-message count. Route the alarm to an SNS topic with an email subscription or other channel someone will actually read.
Send one valid message and one intentionally broken message. Capture proof that the valid one clears, the broken one lands in the DLQ, and the alarm moves into ALARM state.