SQS DLQ Operator
What this skill does
Executes SQS dead-letter queue operations correctly and safely. Runs
deterministic pre-checks before any state-changing CLI, emits the exact
create-queue / set-queue-attributes / start-message-move-task
sequence behind a CONFIRM gate, and verifies DLQ state after apply. The
skill covers five operations: create (DLQ + redrive wiring), tune
(maxReceiveCount adjustment), analyze (why messages landed in DLQ),
replay (StartMessageMoveTask back to source), and monitor (DLQ depth
metrics + alerting).
Every operation surfaces the type-match trap (Standard DLQ for Standard
queue, FIFO DLQ for FIFO queue — SQS silently drops on mismatch) and
the maxReceiveCount-vs-visibility-timeout race that causes the majority
of false-positive DLQ entries.
Quick navigation
Quick reference — verdict thresholds
| Verdict |
Trigger condition |
Action |
BLOCKED |
One or more pre-checks failed (DLQ type mismatch, source queue missing, no consumer on source, maxReceiveCount < 3, partial-batch gap detected) |
List failures, do NOT execute |
READY |
All pre-checks passed; awaiting CONFIRM gate |
Emit exact CLI sequence, wait for operator yes |
COMPLETED |
Operation applied and post-verification passed (DLQ depth returned to zero, replay task status RUNNING/COMPLETED, source queue receiving) |
Emit post-verify summary |
Priority order for pre-checks (all must pass for READY):
- DLQ type matches source type — Standard DLQ for Standard source, FIFO DLQ (
.fifo suffix) for FIFO source. Mismatch = SQS silently drops redriven messages.
- Source queue exists and is active —
get-queue-url returns a valid URL.
- DLQ retention = 14 days (1209600s) — default 4 days is too short for weekend/holiday coverage.
- maxReceiveCount >= 3 — values of 1 or 2 cause false positives on transient failures.
- Consumer (Lambda/EC2/ECS) attached to source — replaying messages into a source with no consumer just re-accumulates them.
- Visibility timeout >= consumer p99 processing time — if shorter, receive count increments on every redelivery even though the consumer did not fail.
- Lambda event source mapping uses ReportBatchItemFailures (if Lambda) — without it, a single failed message in a batch of 10 causes all 10 to retry, burning maxReceiveCount.
Detection lag baselines (2026):
- Message enters DLQ within seconds of the final failed
ReceiveMessage (after maxReceiveCount attempts).
ApproximateNumberOfMessagesVisible on the DLQ updates within 60s.
ApproximateAgeOfOldestMessage tells you how long the DLQ has been accumulating.
Mindset
Three SQS DLQ realities drive every operation:
The DLQ is a symptom, not a root cause. Messages land in the DLQ
because the consumer failed to process them within
maxReceiveCount attempts. Replaying them without fixing the
consumer just re-accumulates them. Always diagnose the root cause
before replaying.
Type mismatch is the silent killer. A Standard source with a FIFO
DLQ (or vice versa) does NOT error at redrive-policy configuration
time. SQS silently drops the redriven messages — they vanish from
the source, never appear in the DLQ, and are gone forever. This is
the #1 DLQ deployment bug.
Visibility-timeout race is the #1 false-positive cause. If
VisibilityTimeout on the source is shorter than the consumer's p99
processing time, the message returns to the queue before processing
completes. SQS increments ApproximateNumberOfReceives on every
delivery. After maxReceiveCount deliveries, the message redrives —
even though the consumer never actually failed. The consumer just
had not finished yet.
Pre-flight: DLQ metadata gate (run before any operation)
Run before classification. get-queue-attributes returns the redrive
policy, DLQ ARN, and source-queue metadata needed to classify the
operation.
Live-account pre-flight (skip if offline plan):
aws sqs get-queue-url --queue-name <source> — confirm source exists.
aws sqs get-queue-attributes --queue-url <source> --attribute-names All — capture RedrivePolicy, VisibilityTimeout, QueueArn, FifoQueue.
aws sqs get-queue-url --queue-name <dlq> — confirm DLQ exists (if create operation, this is the pre-create check).
aws sqs get-queue-attributes --queue-url <dlq> --attribute-names All — capture MessageRetentionPeriod, FifoQueue, RedriveAllowPolicy.
aws sqs list-dead-letter-source-queues --queue-url <dlq> — enumerate sources feeding this DLQ.
aws lambda list-event-source-mappings --event-source-arn <source-arn> — capture Lambda consumer config (BatchSize, VisibilityTimeout, FunctionResponseTypes).
aws cloudwatch get-metric-statistics --namespace AWS/SQS --metric-name ApproximateNumberOfMessagesVisible --dimensions QueueName=<dlq-name> — DLQ depth over the last hour.
Malformed input: emit VERDICT: ERROR with reason and remediation.
| Attribute |
Effect on operation |
RedrivePolicy missing on source |
Source has no DLQ — create operation needed. |
RedrivePolicy.deadLetterTargetArn points to wrong-type DLQ |
Type mismatch — silently drops. Tune must fix. |
MessageRetentionPeriod < 1209600 (14 days) |
Messages expire before ops can analyze. Tune to 14 days. |
maxReceiveCount < 3 |
False positives on transient failures. Tune to >= 3. |
VisibilityTimeout < consumer p99 |
Messages redelivered before consumer finishes — #1 false-positive cause. |
Lambda mapping without ReportBatchItemFailures |
Single failed message retries the entire batch — burns maxReceiveCount. |
RedriveAllowPolicy missing on DLQ |
Cross-account redrive defaults to deny. Add allowlist for source account. |
Process — operation planning (apply in order)
Step 0: Expert knowledge — non-obvious SQS DLQ behaviors
Full catalog (silent type mismatch, per-ReceiveMessage counting, VT<p99 false
positives, ESM override, batch retry, v2 API, dedup, purge, retention): references/advanced-patterns.md.
Step 1: Pre-check gate — BLOCKED if any check fails
Run ALL pre-checks. If ANY fails, verdict is BLOCKED with failures in
PRE_CHECKS. Do NOT execute.
For ALL operations:
- Source queue exists (
get-queue-url returns a valid URL).
- DLQ exists (for tune/analyze/replay) or will be created (for create).
- IAM role holds
sqs:CreateQueue / SetQueueAttributes /
StartMessageMoveTask / ReceiveMessage / DeleteMessage.
For create (DLQ + redrive wiring):
4. DLQ type matches source type (FifoQueue attribute identical).
5. DLQ retention = 14 days (1209600s).
6. DLQ name ends in .fifo if source is FIFO.
7. Source has no existing redrive policy (or operator confirms overwrite).
For tune (maxReceiveCount adjustment):
4. Existing RedrivePolicy parses correctly (valid JSON with
deadLetterTargetArn and maxReceiveCount).
5. New maxReceiveCount >= 3.
6. VisibilityTimeout on source >= consumer p99 (else tuning
maxReceiveCount is treating the symptom, not the cause).
For analyze (why messages went to DLQ):
4. DLQ depth > 0 (ApproximateNumberOfMessagesVisible > 0).
5. receive-message on DLQ returns at least one message for inspection.
6. Lambda event source mapping inspected for ReportBatchItemFailures
(if Lambda consumer).
For replay (StartMessageMoveTask):
4. Source queue exists and is the correct destination (verify via
list-dead-letter-source-queues).
5. Source has an active consumer (Lambda mapping or EC2/ECS worker) —
otherwise replayed messages just re-accumulate.
6. Root cause of original DLQ entry is fixed (consumer patched,
visibility timeout increased, poison-pill schema handled) —
otherwise replayed messages redrive again.
7. MaxNumberOfMessagesPerSecond chosen to avoid overwhelming the
consumer (default: unlimited — dangerous for large DLQs).
Step 2: READY — emit operation plan
Emit VERDICT: READY with exact CLI sequence + CONFIRM gate:
- Exact AWS CLI command with all flags populated.
- Expected effect (DLQ depth change, replay task status transition).
- Expected side-effects (consumer receives replayed messages, dedup
window may drop FIFO messages).
- CONFIRM gate prompt.
Step 3: Execute behind CONFIRM gate
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI
(
create-queue, set-queue-attributes, start-message-move-task,
delete-message, purge-queue), emit CONFIRM prompt. Do NOT execute
until confirmed.
- Snapshot current state:
get-queue-attributes --attribute-names All --output json > /tmp/<queue>-backup-$(date +%s).json.
- For replay, capture pre-replay DLQ depth via
ApproximateNumberOfMessagesVisible.
- Execute the CLI.
Step 4: Post-verification — COMPLETED
ALL checks must pass for COMPLETED:
- For create:
get-queue-attributes on source returns the new
RedrivePolicy with correct DLQ ARN and maxReceiveCount.
- For tune:
RedrivePolicy.maxReceiveCount reflects the new value.
- For replay:
list-message-move-tasks shows task status
COMPLETED (or RUNNING for large DLQs — partial COMPLETED).
- For replay: DLQ depth decreasing toward zero; source queue
NumberOfMessagesReceived increasing.
- For analyze: root cause identified and remediation plan emitted
(this is a BLOCKED verdict — analysis does not auto-fix).
If ANY verification fails, emit VERDICT: ERROR — do not claim COMPLETED.
Common DLQ patterns (boilerplate)
Boilerplate command sequences (create Standard/FIFO DLQ + redrive wiring, tune
maxReceiveCount, analyze DLQ, replay via StartMessageMoveTask, partial batch): references/diagnostic-commands.md.
STRICT output contract
Required output structure
Every response MUST begin with this block — no preamble, no
conversational opening:
OPERATION: <create | tune | analyze | replay | monitor>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <source-or-dlq-name>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. CONFIRM: About to <operation> on queue <name> in account <account> region <region>. This will <consequence>. Proceed? (yes/no)
2. <exact CLI command with every flag populated — no placeholders>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
STATE: <DLQ depth, source depth, replay task status>
NOTES: <type-match rationale, maxReceiveCount rationale, visibility-timeout check, replay throttle>
FORBIDDEN output patterns
- NEVER start with conversational preamble ("Let me analyze…") — the
VERDICT block is the FIRST line, always. Use uppercase verdict values
only (
READY, BLOCKED, COMPLETED).
- NEVER omit PRE_CHECKS — every pre-check must appear with
[PASS] or
[FAIL] and a specific reason for each failure.
- NEVER emit a CLI command with placeholder flags in a READY plan —
every flag must be populated with actual values from the input.
- NEVER claim COMPLETED without every POST_VERIFY line showing
[PASS],
and never omit the CONFIRM gate as the first STEPS entry for
state-changing operations.
- NEVER recommend
purge-queue as remediation for poison-pill messages
— it deletes ALL messages and cannot be scoped.
NEVER (things to never do)
NEVER create a Standard DLQ for a FIFO source queue (or vice versa).
SQS silently drops redriven messages on type mismatch — they vanish
from the source and never appear in the DLQ. Always verify the
FifoQueue attribute matches.
NEVER set maxReceiveCount to 1 or 2. A single transient failure
(Lambda throttle, cold start, SDK retry) sends the message
irretrievably to the DLQ. Minimum: 3 (standard), 5 (FIFO where a
poison pill blocks the entire message group).
NEVER replay DLQ messages via StartMessageMoveTask without fixing
the root cause first. If the consumer still fails on the same
poison-pill payload, replayed messages redrive again — burning compute
and re-accumulating in the DLQ. Diagnose, fix, then replay.
NEVER use aws sqs purge-queue as remediation for poison-pill
messages. It deletes ALL messages in the queue (including healthy
ones in flight) and cannot be scoped. Use receive-message +
delete-message for selective removal, or StartMessageMoveTask
for replay after fixing the consumer.
NEVER recommend the legacy Redrive API (deprecated 2022). Use
aws sqs start-message-move-task — it is asynchronous, supports
throttling via MaxNumberOfMessagesPerSecond, and is idempotent per
task ID.
Expert heuristic: false-positive DLQ triage
The most common DLQ diagnosis question: "are these messages genuinely
poisoned, or did they land here due to a configuration race?" Apply
the decision tree in order:
DLQ depth > 0 (ApproximateNumberOfMessagesVisible > 0)
|
├─ Receive a sample message from the DLQ (receive-message, do NOT delete)
│
├─ Inspect the body:
│ ├─ Malformed JSON / missing required field ──────────► Poison pill (consumer cannot parse)
│ ├─ Valid payload but business-rule rejection ────────► Logic poison pill (consumer rejects)
│ └─ Valid payload, consumer should succeed ───────────► Configuration race — keep diagnosing
│
├─ Check ApproximateReceiveCount on the DLQ message:
│ ├─ Equals maxReceiveCount exactly ──────────────────► Normal redrive (consumer tried N times)
│ └─ Less than maxReceiveCount ───────────────────────► Anomalous (possible partial-batch gap or manual move)
│
├─ Check VisibilityTimeout vs consumer p99 processing time:
│ ├─ VisibilityTimeout < p99 ─────────────────────────► FALSE POSITIVE: message returned before consumer finished;
│ │ receive count incremented on every redelivery. Fix: increase
│ │ VisibilityTimeout to >= 6x p99. Replay is safe after fix.
│ └─ VisibilityTimeout >= p99 ─────────────────────────► Keep diagnosing
│
├─ Check Lambda event source mapping for ReportBatchItemFailures:
│ ├─ Missing (batch retries as a unit) ───────────────► FALSE POSITIVE: single failed message caused entire batch
│ │ to retry, burning receive count on healthy messages. Fix:
│ │ enable FunctionResponseTypes=[ReportBatchItemFailures].
│ └─ Present ──────────────────────────────────────────► Keep diagnosing
│
├─ Check consumer CloudWatch Logs / Lambda errors around the redrive timestamp:
│ ├─ Errors present (timeout, exception, IAM denial) ─► Genuine consumer failure. Fix the consumer before replay.
│ └─ No errors ────────────────────────────────────────► Configuration race confirmed (visibility timeout or partial batch)
│
└─ Conclusion:
├─ Poison pill ──────► Selective delete (receive + delete) OR fix consumer to handle gracefully
├─ Config race ──────► Fix config, then replay via StartMessageMoveTask
└─ Consumer failure ─► Patch consumer, then replay
Per-metric root-cause table:
| Symptom |
Likely root cause |
Verification |
| DLQ filling, consumer logs show no errors |
VisibilityTimeout < p99 (false positive) |
Compare Lambda Duration p99 to source VisibilityTimeout |
| DLQ filling, batch of 10 all redriven together |
Missing ReportBatchItemFailures |
Check event source mapping FunctionResponseTypes |
| DLQ filling, consumer throws on a specific payload |
Poison pill (malformed data) |
Receive DLQ message, parse body, reproduce in consumer |
| DLQ filling, consumer shows IAM denial |
IAM policy gap on consumer role |
CloudTrail: AccessDenied around the redrive timestamp |
| DLQ filling, only one MessageGroupId affected (FIFO) |
Head-of-line block on a poison-pill group |
Receive DLQ messages, group by MessageGroupId |
| DLQ filling after a deploy |
Consumer regression (new code throws) |
Correlate DLQ spike timestamp with CodeDeploy deployment |
Pre-flight safety checks (run before any deploy)
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI
(
create-queue, set-queue-attributes, start-message-move-task,
delete-message, purge-queue), emit CONFIRM: and wait for yes.
- Snapshot before modification.
get-queue-attributes --attribute-names All --output json > /tmp/<queue>-backup-$(date +%s).json. The
redrive policy has no version history and no rollback.
- Verify type match before wiring redrive. A Standard source with a
FIFO DLQ silently drops. Always check the DLQ's
FifoQueue attribute.
- Pre-replay DLQ depth snapshot. Capture
ApproximateNumberOfMessagesVisible before StartMessageMoveTask to
measure replay progress.
- Verify consumer is healthy before replay. If the source queue's
consumer is throwing errors, replayed messages redrive again. Check
consumer logs first.
- Throttle replay for large DLQs. Set
MaxNumberOfMessagesPerSecond to a value the consumer can sustain.
Default (unlimited) throttles the consumer and re-triggers the
original failure mode.
Edge-case handling
Edge-case catalog (FIFO replay dedup drops, cross-account RedriveAllowPolicy,
infinite DLQ chain, purge during replay, ESM VT override, metric lag): references/advanced-patterns.md.
Recent AWS features (2024-2026)
Recent AWS features (StartMessageMoveTask GA, ReportBatchItemFailures,
RedriveAllowPolicy, 14-day retention, SSE-SQS, message attributes): references/advanced-patterns.md.
Output format (per operation)
OPERATION: <create | tune | analyze | replay | monitor>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <source-or-dlq-name>
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait or poll command>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
STATE: <DLQ depth, source depth, replay task status>
NOTES: <type-match rationale, maxReceiveCount rationale, visibility-timeout check>
Worked example — create DLQ + redrive (READY)
OPERATION: create
VERDICT: READY
TARGET: prod-orders (source) -> prod-orders-dlq (new DLQ)
PRE_CHECKS:
- [PASS] Source queue prod-orders exists (Standard, VisibilityTimeout=60)
- [PASS] DLQ name prod-orders-dlq available (no existing queue)
- [PASS] DLQ type matches source: Standard (source FifoQueue=false)
- [PASS] DLQ retention will be set to 14 days (1209600s)
- [PASS] maxReceiveCount=5 >= 3 (within safe range for Standard queue)
- [PASS] VisibilityTimeout 60s >= consumer (Lambda) p99 of 8s — no race
- [PASS] Lambda event source mapping has ReportBatchItemFailures enabled
STEPS:
1. CONFIRM: About to create prod-orders-dlq and wire redrive on prod-orders in account 111111111111 region us-east-1. This will CREATE a new DLQ (14-day retention, SSE-SQS) and attach a redrive policy (maxReceiveCount=5). Proceed? (yes/no)
2. aws sqs create-queue --queue-name prod-orders-dlq --attributes MessageRetentionPeriod=1209600,SqsManagedSseEnabled=true
3. DLQ_ARN=$(aws sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/111111111111/prod-orders-dlq --attribute-names QueueArn --query 'Attributes.QueueArn' --output text)
4. aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/111111111111/prod-orders --attributes RedrivePolicy='{"deadLetterTargetArn":"'$DLQ_ARN'","maxReceiveCount":"5"}'
POST_VERIFY:
- (pending execution)
- get-queue-attributes on prod-orders returns RedrivePolicy with DLQ ARN and maxReceiveCount=5
- DLQ exists with MessageRetentionPeriod=1209600
STATE: pending — DLQ empty until messages exhaust maxReceiveCount on source
NOTES:
- Type match: Standard DLQ for Standard source. FIFO DLQ would silently drop redriven messages.
- maxReceiveCount=5 tolerates transient failures (Lambda throttle, cold start, SDK retry). Set to 3 for idempotent consumers that fail fast on real errors.
- VisibilityTimeout 60s >= 6x Lambda p99 (8s) — no false-positive race.
- ReportBatchItemFailures enabled — single failed message retries alone, not the entire batch.
Worked example — replay via StartMessageMoveTask (COMPLETED)
Full worked example (replay of 1247 messages at 100 msg/s; all POST_VERIFY
PASS): references/worked-examples.md.
References (load on demand)
- Diagnostic commands — the Common DLQ patterns boilerplate command sequences moved from SKILL.md
- Worked examples — full replay walkthrough (COMPLETED) moved from SKILL.md
- Advanced patterns — Step 0 expert knowledge, edge-case catalog, recent AWS features moved from SKILL.md
- DLQ operations reference — pre-existing operation decision tree, procedures, cost reference, and worked examples
Domain
AWS CloudOps / App Integration — SQS Dead-Letter Queue Operations.
AWS documentation
1---2name: sqs-dlq-operator3description: 'Operates SQS dead-letter queue lifecycles safely: creates DLQs with correct type (Standard vs FIFO matching source), tunes redrive policy maxReceiveCount against consumer semantics, analyzes DLQ messages to diagnose why redriven (poison-pill payload, visibility-timeout race, IAM denial, partial-batch gap), replays messages back to source via StartMessageMoveTask (2022+ replacement for deprecated Redrive), monitors DLQ depth via ApproximateNumberOfMessagesVisible + ApproximateAgeOfOldestMessage, and wires the latest surfaces — Lambda partial-batch responses (ReportBatchItemFailures) to prevent false positives, redrive allowlists via RedriveAllowPolicy. Enforces safety: type-match check, retention=14 days, CONFIRM gate, snapshot before replay, maxReceiveCount >= 3, idempotent-consumer verification. Emits READY with exact CLI + CONFIRM gate, BLOCKED when pre-checks fail, or COMPLETED when replay confirmed and DLQ depth returned to zero.'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline plan classification. Live-account operations use aws sqs create-queue, set-queue-attributes, get-queue-attributes, list-queues, list-dead-letter-source-queues, start-message-move-task, list-message-move-tasks, receive-message, delete-message, purge-queue, aws lambda list-event-source-mappings / update-event-source-mapping, aws cloudwatch get-metric-statistics, aws logs...6metadata:7 source: https://skillmd.com/skills/jhkchan/sqs-dlq-operator8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '4'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: AppIntegration15 task_type: operate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY | BLOCKED | COMPLETED19 when_to_use: Creating or tuning an SQS dead-letter queue (Standard or FIFO), wiring a redrive policy with the right maxReceiveCount, diagnosing why messages landed in the DLQ (poison pill, visibility-timeout race, IAM denial, partial-batch gap), replaying messages from DLQ back to source via StartMessageMoveTask, monitoring DLQ depth via ApproximateNumberOfMessagesVisible, configuring Lambda partial batch responses (ReportBatchItemFailures) to prevent false-positive DLQ entries, or scoping cross-account redrive via RedriveAllowPolicy. Do NOT invoke for greenfield queue provisioning (use sqs-queue-deployer) or for DLQ policy security audits (use sqs-dlq-policy-auditor).20 activation_triggers: create SQS DLQ, dead-letter queue, tune maxReceiveCount, redrive policy, messages stuck in DLQ, replay DLQ messages, StartMessageMoveTask, poison pill message, DLQ analysis, why messages went to DLQ, DLQ depth alarm, ApproximateNumberOfMessagesVisible, partial batch response, ReportBatchItemFailures, RedriveAllowPolicy, DLQ redrive21 invocation_schema: 'Input: either (a) a DLQ operation intent (create, tune-redrive, analyze, replay) with target queue name(s), OR (b) a DLQ URL for live-account diagnosis or replay. Output: deterministic OPERATION / VERDICT / TARGET / PRE_CHECKS / STEPS / POST_VERIFY / STATE / NOTES block where VERDICT is one of READY, BLOCKED, COMPLETED.'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: SQS, dead-letter queue, DLQ, redrive policy, maxReceiveCount, StartMessageMoveTask, message replay, poison pill, visibility timeout, partial batch response, ReportBatchItemFailures, ApproximateNumberOfMessagesVisible, ApproximateAgeOfOldestMessage, RedriveAllowPolicy, FIFO DLQ, Standard DLQ, Lambda event source mapping, DLQ analysis25 tags: sqs, messaging, app-integration, dead-letter-queue, dlq, operate, redrive, replay26---2728# SQS DLQ Operator2930## What this skill does3132Executes SQS dead-letter queue operations correctly and safely. Runs33deterministic pre-checks before any state-changing CLI, emits the exact34`create-queue` / `set-queue-attributes` / `start-message-move-task`35sequence behind a CONFIRM gate, and verifies DLQ state after apply. The36skill covers five operations: create (DLQ + redrive wiring), tune37(maxReceiveCount adjustment), analyze (why messages landed in DLQ),38replay (StartMessageMoveTask back to source), and monitor (DLQ depth39metrics + alerting).4041Every operation surfaces the type-match trap (Standard DLQ for Standard42queue, FIFO DLQ for FIFO queue — SQS silently drops on mismatch) and43the maxReceiveCount-vs-visibility-timeout race that causes the majority44of false-positive DLQ entries.4546## Quick navigation4748| # | Section | Jump when |49|---|---|---|50| 1 | [Quick reference](#quick-reference--verdict-thresholds) | Verdict thresholds + pre-check priority |51| 2 | [Pre-flight gate](#pre-flight-dlq-metadata-gate) | Before any CLI — short-circuit broken sources |52| 3 | [Process — operations](#process--operation-planning-apply-in-order) | Per-operation planning: create, tune, analyze, replay |53| 4 | [Common patterns](#common-dlq-patterns-boilerplate) | DLQ creation, redrive wiring, replay boilerplate |54| 5 | [STRICT output contract](#strict-output-contract) | The exact VERDICT block the skill emits |55| 6 | [NEVER anti-patterns](#never-things-to-never-do) | Top taboos |56| 7 | [Expert heuristic](#expert-heuristic-false-positive-dlq-triage) | "Why did this land in the DLQ?" decision tree |57| 8 | [Recent AWS features](#recent-aws-features-2024-2026) | What changed in 24 months |5859## Quick reference — verdict thresholds6061| Verdict | Trigger condition | Action |62|---|---|---|63| `BLOCKED` | One or more pre-checks failed (DLQ type mismatch, source queue missing, no consumer on source, maxReceiveCount < 3, partial-batch gap detected) | List failures, do NOT execute |64| `READY` | All pre-checks passed; awaiting CONFIRM gate | Emit exact CLI sequence, wait for operator yes |65| `COMPLETED` | Operation applied and post-verification passed (DLQ depth returned to zero, replay task status RUNNING/COMPLETED, source queue receiving) | Emit post-verify summary |6667**Priority order for pre-checks (all must pass for READY):**68691. **DLQ type matches source type** — Standard DLQ for Standard source, FIFO DLQ (`.fifo` suffix) for FIFO source. Mismatch = SQS silently drops redriven messages.702. **Source queue exists and is active** — `get-queue-url` returns a valid URL.713. **DLQ retention = 14 days (1209600s)** — default 4 days is too short for weekend/holiday coverage.724. **maxReceiveCount >= 3** — values of 1 or 2 cause false positives on transient failures.735. **Consumer (Lambda/EC2/ECS) attached to source** — replaying messages into a source with no consumer just re-accumulates them.746. **Visibility timeout >= consumer p99 processing time** — if shorter, receive count increments on every redelivery even though the consumer did not fail.757. **Lambda event source mapping uses ReportBatchItemFailures** (if Lambda) — without it, a single failed message in a batch of 10 causes all 10 to retry, burning maxReceiveCount.7677**Detection lag baselines (2026):**78- Message enters DLQ within seconds of the final failed `ReceiveMessage` (after maxReceiveCount attempts).79- `ApproximateNumberOfMessagesVisible` on the DLQ updates within 60s.80- `ApproximateAgeOfOldestMessage` tells you how long the DLQ has been accumulating.8182## Mindset8384Three SQS DLQ realities drive every operation:8586- **The DLQ is a symptom, not a root cause.** Messages land in the DLQ87 because the consumer failed to process them within88 `maxReceiveCount` attempts. Replaying them without fixing the89 consumer just re-accumulates them. Always diagnose the root cause90 before replaying.9192- **Type mismatch is the silent killer.** A Standard source with a FIFO93 DLQ (or vice versa) does NOT error at redrive-policy configuration94 time. SQS silently drops the redriven messages — they vanish from95 the source, never appear in the DLQ, and are gone forever. This is96 the #1 DLQ deployment bug.9798- **Visibility-timeout race is the #1 false-positive cause.** If99 `VisibilityTimeout` on the source is shorter than the consumer's p99100 processing time, the message returns to the queue before processing101 completes. SQS increments `ApproximateNumberOfReceives` on every102 delivery. After `maxReceiveCount` deliveries, the message redrives —103 even though the consumer never actually failed. The consumer just104 had not finished yet.105106## Pre-flight: DLQ metadata gate (run before any operation)107108Run before classification. `get-queue-attributes` returns the redrive109policy, DLQ ARN, and source-queue metadata needed to classify the110operation.111112**Live-account pre-flight (skip if offline plan):**1131. `aws sqs get-queue-url --queue-name <source>` — confirm source exists.1142. `aws sqs get-queue-attributes --queue-url <source> --attribute-names All` — capture `RedrivePolicy`, `VisibilityTimeout`, `QueueArn`, `FifoQueue`.1153. `aws sqs get-queue-url --queue-name <dlq>` — confirm DLQ exists (if create operation, this is the pre-create check).1164. `aws sqs get-queue-attributes --queue-url <dlq> --attribute-names All` — capture `MessageRetentionPeriod`, `FifoQueue`, `RedriveAllowPolicy`.1175. `aws sqs list-dead-letter-source-queues --queue-url <dlq>` — enumerate sources feeding this DLQ.1186. `aws lambda list-event-source-mappings --event-source-arn <source-arn>` — capture Lambda consumer config (BatchSize, VisibilityTimeout, FunctionResponseTypes).1197. `aws cloudwatch get-metric-statistics --namespace AWS/SQS --metric-name ApproximateNumberOfMessagesVisible --dimensions QueueName=<dlq-name>` — DLQ depth over the last hour.120121**Malformed input:** emit `VERDICT: ERROR` with reason and remediation.122123| Attribute | Effect on operation |124|---|---|125| `RedrivePolicy` missing on source | Source has no DLQ — create operation needed. |126| `RedrivePolicy.deadLetterTargetArn` points to wrong-type DLQ | Type mismatch — silently drops. Tune must fix. |127| `MessageRetentionPeriod` < 1209600 (14 days) | Messages expire before ops can analyze. Tune to 14 days. |128| `maxReceiveCount` < 3 | False positives on transient failures. Tune to >= 3. |129| `VisibilityTimeout` < consumer p99 | Messages redelivered before consumer finishes — #1 false-positive cause. |130| Lambda mapping without `ReportBatchItemFailures` | Single failed message retries the entire batch — burns maxReceiveCount. |131| `RedriveAllowPolicy` missing on DLQ | Cross-account redrive defaults to deny. Add allowlist for source account. |132133## Process — operation planning (apply in order)134135### Step 0: Expert knowledge — non-obvious SQS DLQ behaviors136137Full catalog (silent type mismatch, per-ReceiveMessage counting, VT<p99 false138positives, ESM override, batch retry, v2 API, dedup, purge, retention): [references/advanced-patterns.md](references/advanced-patterns.md).139140### Step 1: Pre-check gate — BLOCKED if any check fails141142Run ALL pre-checks. If ANY fails, verdict is BLOCKED with failures in143PRE_CHECKS. Do NOT execute.144145**For ALL operations:**1461. Source queue exists (`get-queue-url` returns a valid URL).1472. DLQ exists (for tune/analyze/replay) or will be created (for create).1483. IAM role holds `sqs:CreateQueue` / `SetQueueAttributes` /149 `StartMessageMoveTask` / `ReceiveMessage` / `DeleteMessage`.150151**For create (DLQ + redrive wiring):**1524. DLQ type matches source type (`FifoQueue` attribute identical).1535. DLQ retention = 14 days (1209600s).1546. DLQ name ends in `.fifo` if source is FIFO.1557. Source has no existing redrive policy (or operator confirms overwrite).156157**For tune (maxReceiveCount adjustment):**1584. Existing `RedrivePolicy` parses correctly (valid JSON with159 `deadLetterTargetArn` and `maxReceiveCount`).1605. New maxReceiveCount >= 3.1616. `VisibilityTimeout` on source >= consumer p99 (else tuning162 maxReceiveCount is treating the symptom, not the cause).163164**For analyze (why messages went to DLQ):**1654. DLQ depth > 0 (`ApproximateNumberOfMessagesVisible` > 0).1665. `receive-message` on DLQ returns at least one message for inspection.1676. Lambda event source mapping inspected for `ReportBatchItemFailures`168 (if Lambda consumer).169170**For replay (StartMessageMoveTask):**1714. Source queue exists and is the correct destination (verify via172 `list-dead-letter-source-queues`).1735. Source has an active consumer (Lambda mapping or EC2/ECS worker) —174 otherwise replayed messages just re-accumulate.1756. Root cause of original DLQ entry is fixed (consumer patched,176 visibility timeout increased, poison-pill schema handled) —177 otherwise replayed messages redrive again.1787. `MaxNumberOfMessagesPerSecond` chosen to avoid overwhelming the179 consumer (default: unlimited — dangerous for large DLQs).180181### Step 2: READY — emit operation plan182183Emit `VERDICT: READY` with exact CLI sequence + CONFIRM gate:184- Exact AWS CLI command with all flags populated.185- Expected effect (DLQ depth change, replay task status transition).186- Expected side-effects (consumer receives replayed messages, dedup187 window may drop FIFO messages).188- CONFIRM gate prompt.189190### Step 3: Execute behind CONFIRM gate191192- **MANDATORY CONFIRMATION GATE.** Before any state-changing CLI193 (`create-queue`, `set-queue-attributes`, `start-message-move-task`,194 `delete-message`, `purge-queue`), emit CONFIRM prompt. Do NOT execute195 until confirmed.196- Snapshot current state: `get-queue-attributes --attribute-names All197 --output json > /tmp/<queue>-backup-$(date +%s).json`.198- For replay, capture pre-replay DLQ depth via199 `ApproximateNumberOfMessagesVisible`.200- Execute the CLI.201202### Step 4: Post-verification — COMPLETED203204ALL checks must pass for `COMPLETED`:2051. For create: `get-queue-attributes` on source returns the new206 `RedrivePolicy` with correct DLQ ARN and maxReceiveCount.2072. For tune: `RedrivePolicy.maxReceiveCount` reflects the new value.2083. For replay: `list-message-move-tasks` shows task status209 `COMPLETED` (or `RUNNING` for large DLQs — partial COMPLETED).2104. For replay: DLQ depth decreasing toward zero; source queue211 `NumberOfMessagesReceived` increasing.2125. For analyze: root cause identified and remediation plan emitted213 (this is a BLOCKED verdict — analysis does not auto-fix).214215If ANY verification fails, emit `VERDICT: ERROR` — do not claim COMPLETED.216217## Common DLQ patterns (boilerplate)218219Boilerplate command sequences (create Standard/FIFO DLQ + redrive wiring, tune220maxReceiveCount, analyze DLQ, replay via StartMessageMoveTask, partial batch): [references/diagnostic-commands.md](references/diagnostic-commands.md).221222## STRICT output contract223224### Required output structure225226Every response MUST begin with this block — no preamble, no227conversational opening:228229```text230OPERATION: <create | tune | analyze | replay | monitor>231VERDICT: READY | BLOCKED | COMPLETED232TARGET: <source-or-dlq-name>233PRE_CHECKS:234 - [PASS] <check description>235 - [FAIL] <check description> — <reason>236STEPS:237 1. CONFIRM: About to <operation> on queue <name> in account <account> region <region>. This will <consequence>. Proceed? (yes/no)238 2. <exact CLI command with every flag populated — no placeholders>239POST_VERIFY:240 - [PASS] <verification description>241 - [FAIL] <verification description> — <reason>242STATE: <DLQ depth, source depth, replay task status>243NOTES: <type-match rationale, maxReceiveCount rationale, visibility-timeout check, replay throttle>244```245246### FORBIDDEN output patterns247248- NEVER start with conversational preamble ("Let me analyze…") — the249 VERDICT block is the FIRST line, always. Use uppercase verdict values250 only (`READY`, `BLOCKED`, `COMPLETED`).251- NEVER omit PRE_CHECKS — every pre-check must appear with `[PASS]` or252 `[FAIL]` and a specific reason for each failure.253- NEVER emit a CLI command with placeholder flags in a READY plan —254 every flag must be populated with actual values from the input.255- NEVER claim COMPLETED without every POST_VERIFY line showing `[PASS]`,256 and never omit the CONFIRM gate as the first STEPS entry for257 state-changing operations.258- NEVER recommend `purge-queue` as remediation for poison-pill messages259 — it deletes ALL messages and cannot be scoped.260261## NEVER (things to never do)262263- NEVER create a Standard DLQ for a FIFO source queue (or vice versa).264 SQS silently drops redriven messages on type mismatch — they vanish265 from the source and never appear in the DLQ. Always verify the266 `FifoQueue` attribute matches.267268- NEVER set `maxReceiveCount` to 1 or 2. A single transient failure269 (Lambda throttle, cold start, SDK retry) sends the message270 irretrievably to the DLQ. Minimum: 3 (standard), 5 (FIFO where a271 poison pill blocks the entire message group).272273- NEVER replay DLQ messages via `StartMessageMoveTask` without fixing274 the root cause first. If the consumer still fails on the same275 poison-pill payload, replayed messages redrive again — burning compute276 and re-accumulating in the DLQ. Diagnose, fix, then replay.277278- NEVER use `aws sqs purge-queue` as remediation for poison-pill279 messages. It deletes ALL messages in the queue (including healthy280 ones in flight) and cannot be scoped. Use `receive-message` +281 `delete-message` for selective removal, or `StartMessageMoveTask`282 for replay after fixing the consumer.283284- NEVER recommend the legacy `Redrive` API (deprecated 2022). Use285 `aws sqs start-message-move-task` — it is asynchronous, supports286 throttling via `MaxNumberOfMessagesPerSecond`, and is idempotent per287 task ID.288289## Expert heuristic: false-positive DLQ triage290291The most common DLQ diagnosis question: "are these messages genuinely292poisoned, or did they land here due to a configuration race?" Apply293the decision tree in order:294295```296DLQ depth > 0 (ApproximateNumberOfMessagesVisible > 0)297 |298 ├─ Receive a sample message from the DLQ (receive-message, do NOT delete)299 │300 ├─ Inspect the body:301 │ ├─ Malformed JSON / missing required field ──────────► Poison pill (consumer cannot parse)302 │ ├─ Valid payload but business-rule rejection ────────► Logic poison pill (consumer rejects)303 │ └─ Valid payload, consumer should succeed ───────────► Configuration race — keep diagnosing304 │305 ├─ Check ApproximateReceiveCount on the DLQ message:306 │ ├─ Equals maxReceiveCount exactly ──────────────────► Normal redrive (consumer tried N times)307 │ └─ Less than maxReceiveCount ───────────────────────► Anomalous (possible partial-batch gap or manual move)308 │309 ├─ Check VisibilityTimeout vs consumer p99 processing time:310 │ ├─ VisibilityTimeout < p99 ─────────────────────────► FALSE POSITIVE: message returned before consumer finished;311 │ │ receive count incremented on every redelivery. Fix: increase312 │ │ VisibilityTimeout to >= 6x p99. Replay is safe after fix.313 │ └─ VisibilityTimeout >= p99 ─────────────────────────► Keep diagnosing314 │315 ├─ Check Lambda event source mapping for ReportBatchItemFailures:316 │ ├─ Missing (batch retries as a unit) ───────────────► FALSE POSITIVE: single failed message caused entire batch317 │ │ to retry, burning receive count on healthy messages. Fix:318 │ │ enable FunctionResponseTypes=[ReportBatchItemFailures].319 │ └─ Present ──────────────────────────────────────────► Keep diagnosing320 │321 ├─ Check consumer CloudWatch Logs / Lambda errors around the redrive timestamp:322 │ ├─ Errors present (timeout, exception, IAM denial) ─► Genuine consumer failure. Fix the consumer before replay.323 │ └─ No errors ────────────────────────────────────────► Configuration race confirmed (visibility timeout or partial batch)324 │325 └─ Conclusion:326 ├─ Poison pill ──────► Selective delete (receive + delete) OR fix consumer to handle gracefully327 ├─ Config race ──────► Fix config, then replay via StartMessageMoveTask328 └─ Consumer failure ─► Patch consumer, then replay329```330331**Per-metric root-cause table:**332333| Symptom | Likely root cause | Verification |334|---|---|---|335| DLQ filling, consumer logs show no errors | VisibilityTimeout < p99 (false positive) | Compare Lambda Duration p99 to source VisibilityTimeout |336| DLQ filling, batch of 10 all redriven together | Missing ReportBatchItemFailures | Check event source mapping FunctionResponseTypes |337| DLQ filling, consumer throws on a specific payload | Poison pill (malformed data) | Receive DLQ message, parse body, reproduce in consumer |338| DLQ filling, consumer shows IAM denial | IAM policy gap on consumer role | CloudTrail: AccessDenied around the redrive timestamp |339| DLQ filling, only one MessageGroupId affected (FIFO) | Head-of-line block on a poison-pill group | Receive DLQ messages, group by MessageGroupId |340| DLQ filling after a deploy | Consumer regression (new code throws) | Correlate DLQ spike timestamp with CodeDeploy deployment |341342## Pre-flight safety checks (run before any deploy)343344- **MANDATORY CONFIRMATION GATE.** Before any state-changing CLI345 (`create-queue`, `set-queue-attributes`, `start-message-move-task`,346 `delete-message`, `purge-queue`), emit `CONFIRM:` and wait for `yes`.347- **Snapshot before modification.** `get-queue-attributes --attribute-names348 All --output json > /tmp/<queue>-backup-$(date +%s).json`. The349 redrive policy has no version history and no rollback.350- **Verify type match before wiring redrive.** A Standard source with a351 FIFO DLQ silently drops. Always check the DLQ's `FifoQueue` attribute.352- **Pre-replay DLQ depth snapshot.** Capture353 `ApproximateNumberOfMessagesVisible` before `StartMessageMoveTask` to354 measure replay progress.355- **Verify consumer is healthy before replay.** If the source queue's356 consumer is throwing errors, replayed messages redrive again. Check357 consumer logs first.358- **Throttle replay for large DLQs.** Set359 `MaxNumberOfMessagesPerSecond` to a value the consumer can sustain.360 Default (unlimited) throttles the consumer and re-triggers the361 original failure mode.362363## Edge-case handling364365Edge-case catalog (FIFO replay dedup drops, cross-account RedriveAllowPolicy,366infinite DLQ chain, purge during replay, ESM VT override, metric lag): [references/advanced-patterns.md](references/advanced-patterns.md).367368## Recent AWS features (2024-2026)369370Recent AWS features (StartMessageMoveTask GA, ReportBatchItemFailures,371RedriveAllowPolicy, 14-day retention, SSE-SQS, message attributes): [references/advanced-patterns.md](references/advanced-patterns.md).372373## Output format (per operation)374375```text376OPERATION: <create | tune | analyze | replay | monitor>377VERDICT: READY | BLOCKED | COMPLETED378TARGET: <source-or-dlq-name>379PRE_CHECKS:380 - [PASS] <check description>381 - [FAIL] <check description> — <reason>382STEPS:383 1. <CLI command with flags populated>384 2. <wait or poll command>385POST_VERIFY:386 - [PASS] <verification description>387 - [FAIL] <verification description> — <reason>388STATE: <DLQ depth, source depth, replay task status>389NOTES: <type-match rationale, maxReceiveCount rationale, visibility-timeout check>390```391392### Worked example — create DLQ + redrive (READY)393394```text395OPERATION: create396VERDICT: READY397TARGET: prod-orders (source) -> prod-orders-dlq (new DLQ)398PRE_CHECKS:399 - [PASS] Source queue prod-orders exists (Standard, VisibilityTimeout=60)400 - [PASS] DLQ name prod-orders-dlq available (no existing queue)401 - [PASS] DLQ type matches source: Standard (source FifoQueue=false)402 - [PASS] DLQ retention will be set to 14 days (1209600s)403 - [PASS] maxReceiveCount=5 >= 3 (within safe range for Standard queue)404 - [PASS] VisibilityTimeout 60s >= consumer (Lambda) p99 of 8s — no race405 - [PASS] Lambda event source mapping has ReportBatchItemFailures enabled406STEPS:407 1. CONFIRM: About to create prod-orders-dlq and wire redrive on prod-orders in account 111111111111 region us-east-1. This will CREATE a new DLQ (14-day retention, SSE-SQS) and attach a redrive policy (maxReceiveCount=5). Proceed? (yes/no)408 2. aws sqs create-queue --queue-name prod-orders-dlq --attributes MessageRetentionPeriod=1209600,SqsManagedSseEnabled=true409 3. DLQ_ARN=$(aws sqs get-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/111111111111/prod-orders-dlq --attribute-names QueueArn --query 'Attributes.QueueArn' --output text)410 4. aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/111111111111/prod-orders --attributes RedrivePolicy='{"deadLetterTargetArn":"'$DLQ_ARN'","maxReceiveCount":"5"}'411POST_VERIFY:412 - (pending execution)413 - get-queue-attributes on prod-orders returns RedrivePolicy with DLQ ARN and maxReceiveCount=5414 - DLQ exists with MessageRetentionPeriod=1209600415STATE: pending — DLQ empty until messages exhaust maxReceiveCount on source416NOTES:417 - Type match: Standard DLQ for Standard source. FIFO DLQ would silently drop redriven messages.418 - maxReceiveCount=5 tolerates transient failures (Lambda throttle, cold start, SDK retry). Set to 3 for idempotent consumers that fail fast on real errors.419 - VisibilityTimeout 60s >= 6x Lambda p99 (8s) — no false-positive race.420 - ReportBatchItemFailures enabled — single failed message retries alone, not the entire batch.421```422423### Worked example — replay via StartMessageMoveTask (COMPLETED)424425Full worked example (replay of 1247 messages at 100 msg/s; all POST_VERIFY426PASS): [references/worked-examples.md](references/worked-examples.md).427428## References (load on demand)429430- [Diagnostic commands](references/diagnostic-commands.md) — the Common DLQ patterns boilerplate command sequences moved from SKILL.md431- [Worked examples](references/worked-examples.md) — full replay walkthrough (COMPLETED) moved from SKILL.md432- [Advanced patterns](references/advanced-patterns.md) — Step 0 expert knowledge, edge-case catalog, recent AWS features moved from SKILL.md433- [DLQ operations reference](references/dlq-operations-reference.md) — pre-existing operation decision tree, procedures, cost reference, and worked examples434435## Domain436437AWS CloudOps / App Integration — SQS Dead-Letter Queue Operations.438439## AWS documentation440441- **Amazon SQS Developer Guide** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html442- **SQS Dead-Letter Queues** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html443- **SQS Message Lifecycle** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-lifecycle.html444- **SQS RedrivePolicy** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html445- **SQS StartMessageMoveTask** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_StartMessageMoveTask.html446- **SQS CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/sqs/447- **Lambda Event Source Mapping (SQS)** — https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html448- **SQS Partial Batch Responses** — https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting449- **SQS Visibility Timeout** — https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html