@composurecdk/sqs 0.8.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -13
- package/dist/commonjs/dlq-alarm-defaults.d.ts +53 -0
- package/dist/commonjs/dlq-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/dlq-alarm-defaults.js +53 -0
- package/dist/commonjs/dlq-alarm-defaults.js.map +1 -0
- package/dist/commonjs/dlq-defaults.d.ts +19 -0
- package/dist/commonjs/dlq-defaults.d.ts.map +1 -0
- package/dist/commonjs/dlq-defaults.js +22 -0
- package/dist/commonjs/dlq-defaults.js.map +1 -0
- package/dist/commonjs/grants.d.ts +19 -0
- package/dist/commonjs/grants.d.ts.map +1 -0
- package/dist/commonjs/grants.js +28 -0
- package/dist/commonjs/grants.js.map +1 -0
- package/dist/commonjs/index.d.ts +6 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +7 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/queue-alarm-config.d.ts +47 -11
- package/dist/commonjs/queue-alarm-config.d.ts.map +1 -1
- package/dist/commonjs/queue-alarm-defaults.d.ts +46 -11
- package/dist/commonjs/queue-alarm-defaults.d.ts.map +1 -1
- package/dist/commonjs/queue-alarm-defaults.js +11 -5
- package/dist/commonjs/queue-alarm-defaults.js.map +1 -1
- package/dist/commonjs/queue-alarm-profiles.d.ts +37 -0
- package/dist/commonjs/queue-alarm-profiles.d.ts.map +1 -0
- package/dist/commonjs/queue-alarm-profiles.js +96 -0
- package/dist/commonjs/queue-alarm-profiles.js.map +1 -0
- package/dist/commonjs/queue-alarms.d.ts +8 -2
- package/dist/commonjs/queue-alarms.d.ts.map +1 -1
- package/dist/commonjs/queue-alarms.js +49 -42
- package/dist/commonjs/queue-alarms.js.map +1 -1
- package/dist/commonjs/queue-builder.d.ts +70 -53
- package/dist/commonjs/queue-builder.d.ts.map +1 -1
- package/dist/commonjs/queue-builder.js +27 -68
- package/dist/commonjs/queue-builder.js.map +1 -1
- package/dist/commonjs/queue-props.d.ts +93 -0
- package/dist/commonjs/queue-props.d.ts.map +1 -0
- package/dist/commonjs/queue-props.js +16 -0
- package/dist/commonjs/queue-props.js.map +1 -0
- package/dist/commonjs/queue-role.d.ts +28 -0
- package/dist/commonjs/queue-role.d.ts.map +1 -0
- package/dist/commonjs/queue-role.js +13 -0
- package/dist/commonjs/queue-role.js.map +1 -0
- package/dist/commonjs/queue-validation.d.ts +12 -0
- package/dist/commonjs/queue-validation.d.ts.map +1 -0
- package/dist/commonjs/queue-validation.js +142 -0
- package/dist/commonjs/queue-validation.js.map +1 -0
- package/dist/esm/dlq-alarm-defaults.d.ts +53 -0
- package/dist/esm/dlq-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/dlq-alarm-defaults.js +50 -0
- package/dist/esm/dlq-alarm-defaults.js.map +1 -0
- package/dist/esm/dlq-defaults.d.ts +19 -0
- package/dist/esm/dlq-defaults.d.ts.map +1 -0
- package/dist/esm/dlq-defaults.js +19 -0
- package/dist/esm/dlq-defaults.js.map +1 -0
- package/dist/esm/grants.d.ts +19 -0
- package/dist/esm/grants.d.ts.map +1 -0
- package/dist/esm/grants.js +25 -0
- package/dist/esm/grants.js.map +1 -0
- package/dist/esm/index.d.ts +6 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/queue-alarm-config.d.ts +47 -11
- package/dist/esm/queue-alarm-config.d.ts.map +1 -1
- package/dist/esm/queue-alarm-defaults.d.ts +46 -11
- package/dist/esm/queue-alarm-defaults.d.ts.map +1 -1
- package/dist/esm/queue-alarm-defaults.js +11 -5
- package/dist/esm/queue-alarm-defaults.js.map +1 -1
- package/dist/esm/queue-alarm-profiles.d.ts +37 -0
- package/dist/esm/queue-alarm-profiles.d.ts.map +1 -0
- package/dist/esm/queue-alarm-profiles.js +92 -0
- package/dist/esm/queue-alarm-profiles.js.map +1 -0
- package/dist/esm/queue-alarms.d.ts +8 -2
- package/dist/esm/queue-alarms.d.ts.map +1 -1
- package/dist/esm/queue-alarms.js +50 -43
- package/dist/esm/queue-alarms.js.map +1 -1
- package/dist/esm/queue-builder.d.ts +70 -53
- package/dist/esm/queue-builder.d.ts.map +1 -1
- package/dist/esm/queue-builder.js +27 -68
- package/dist/esm/queue-builder.js.map +1 -1
- package/dist/esm/queue-props.d.ts +93 -0
- package/dist/esm/queue-props.d.ts.map +1 -0
- package/dist/esm/queue-props.js +13 -0
- package/dist/esm/queue-props.js.map +1 -0
- package/dist/esm/queue-role.d.ts +28 -0
- package/dist/esm/queue-role.d.ts.map +1 -0
- package/dist/esm/queue-role.js +9 -0
- package/dist/esm/queue-role.js.map +1 -0
- package/dist/esm/queue-validation.d.ts +12 -0
- package/dist/esm/queue-validation.d.ts.map +1 -0
- package/dist/esm/queue-validation.js +139 -0
- package/dist/esm/queue-validation.js.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,23 +4,109 @@ SQS queue builder for [ComposureCDK](../../README.md).
|
|
|
4
4
|
|
|
5
5
|
This package provides a fluent builder for SQS queues with secure, AWS-recommended defaults and built-in CloudWatch alarms. It wraps the CDK [Queue](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.Queue.html) construct — refer to the CDK documentation for the full set of configurable properties.
|
|
6
6
|
|
|
7
|
-
## Queue
|
|
7
|
+
## Queue roles
|
|
8
|
+
|
|
9
|
+
`createQueueBuilder(role?)` is the single entry point for every queue type. The role selects the builder's **typed prop surface** (props that don't apply to a role don't exist on its builder), its defaults, its recommended-alarm profile, and its build-time validation:
|
|
10
|
+
|
|
11
|
+
| Role | Queue type | Surface & behaviour |
|
|
12
|
+
| ---------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `"standard"` (default) | Standard, primary | FIFO-only props excluded from the type (and rejected at build). |
|
|
14
|
+
| `"fifo"` | FIFO, primary | `fifo: true` always; `queueName` typed to require the `.fifo` suffix; high-throughput mode validated. |
|
|
15
|
+
| `"dlq"` | Standard, dead-letter | 14-day retention; inverted alarm set (any message alerts); `deadLetterQueue` excluded — a DLQ is terminal. |
|
|
16
|
+
| `"fifo-dlq"` | FIFO, dead-letter | The FIFO surface combined with the DLQ defaults and alarms — AWS requires a FIFO source's DLQ to itself be FIFO. |
|
|
17
|
+
|
|
18
|
+
Every role shares the same [secure defaults](#secure-defaults), the same `Lifecycle`/`compose` integration, the same `addAlarm` escape hatch, and the same `QueueBuilderResult` shape. The role is ordinary builder state: `.copy()` preserves it, and adding a future role is a new table entry, not a new entry point.
|
|
8
19
|
|
|
9
20
|
```ts
|
|
10
21
|
import { Duration } from "aws-cdk-lib";
|
|
11
22
|
import { createQueueBuilder } from "@composurecdk/sqs";
|
|
12
23
|
|
|
13
|
-
const orders = createQueueBuilder()
|
|
24
|
+
const orders = createQueueBuilder() // "standard"
|
|
14
25
|
.queueName("orders")
|
|
15
26
|
.visibilityTimeout(Duration.seconds(60))
|
|
16
27
|
.build(stack, "Orders");
|
|
17
28
|
```
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
## FIFO queues (`"fifo"`)
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { DeduplicationScope, FifoThroughputLimit } from "aws-cdk-lib/aws-sqs";
|
|
34
|
+
|
|
35
|
+
const orderEvents = createQueueBuilder("fifo")
|
|
36
|
+
.queueName("order-events.fifo") // type requires the `.fifo` suffix
|
|
37
|
+
.contentBasedDeduplication(true)
|
|
38
|
+
.build(stack, "OrderEvents");
|
|
39
|
+
|
|
40
|
+
// High-throughput FIFO — the dedup scope pairing is validated at build.
|
|
41
|
+
const highTps = createQueueBuilder("fifo")
|
|
42
|
+
.queueName("order-events-ht.fifo")
|
|
43
|
+
.fifoThroughputLimit(FifoThroughputLimit.PER_MESSAGE_GROUP_ID)
|
|
44
|
+
.deduplicationScope(DeduplicationScope.MESSAGE_GROUP)
|
|
45
|
+
.build(stack, "OrderEventsHt");
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
FIFO-aware behaviour:
|
|
49
|
+
|
|
50
|
+
- **`fifo: true` always.** The prop is not settable; the role is the switch.
|
|
51
|
+
- **`queueName` is typed `` `${string}.fifo` ``** — AWS requires the suffix, so a bad name fails at compile time instead of synth. Omit the name to let CloudFormation generate a valid one.
|
|
52
|
+
- **High-throughput coherence**: `fifoThroughputLimit: PER_MESSAGE_GROUP_ID` without `deduplicationScope: MESSAGE_GROUP` throws at build ([high-throughput FIFO](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/high-throughput-fifo.html)).
|
|
53
|
+
- **Redrive type match**: a FIFO queue redriving to a standard DLQ (or vice versa) throws at build — AWS rejects the mismatch at deploy time otherwise.
|
|
54
|
+
- **Alarms**: same set and thresholds as a standard queue. Since [November 2024](https://aws.amazon.com/about-aws/whats-new/2024/11/amazon-sqs-increases-in-flight-limit-fifo-queues/) FIFO queues share the standard 120,000 in-flight quota, so the in-flight threshold applies unchanged. FIFO throughput ceilings (300 TPS, or 3,000 with high-throughput mode) have no dedicated CloudWatch metric — if you need a "throughput wall" signal, add a custom alarm on `NumberOfMessagesSent` via `addAlarm`.
|
|
55
|
+
|
|
56
|
+
## Dead-letter queues (`"dlq"`, `"fifo-dlq"`)
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { compose, ref } from "@composurecdk/core";
|
|
60
|
+
|
|
61
|
+
const system = compose(
|
|
62
|
+
{
|
|
63
|
+
ordersDlq: createQueueBuilder("dlq"),
|
|
64
|
+
orders: createQueueBuilder().deadLetterQueue(
|
|
65
|
+
ref("ordersDlq", (r) => ({ queue: r.queue, maxReceiveCount: 5 })),
|
|
66
|
+
),
|
|
67
|
+
},
|
|
68
|
+
{ ordersDlq: [], orders: ["ordersDlq"] },
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// A FIFO primary requires a FIFO DLQ — one role, not a prop combination:
|
|
72
|
+
const orderEventsDlq = createQueueBuilder("fifo-dlq")
|
|
73
|
+
.queueName("order-events-dlq.fifo")
|
|
74
|
+
.build(stack, "OrderEventsDlq");
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
DLQ-specific behaviour:
|
|
78
|
+
|
|
79
|
+
| Property | Default | Rationale |
|
|
80
|
+
| ----------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `retentionPeriod` | `Duration.days(14)` | The SQS maximum. A DLQ exists to give operators a window to investigate and redrive failed messages — maximizing that window is the point. Exported as `DLQ_QUEUE_DEFAULTS`. |
|
|
82
|
+
|
|
83
|
+
- **`deadLetterQueue` is excluded** from the type (and rejected at build): a DLQ is the terminal destination for failed messages. A queue with its own redrive policy is a primary queue.
|
|
84
|
+
- Consider restricting which queues may redrive into the DLQ via `.redriveAllowPolicy(...)`.
|
|
85
|
+
|
|
86
|
+
### DLQ alarms
|
|
87
|
+
|
|
88
|
+
The recommended-alarm set inverts relative to a primary queue — the defaults are exported as `DLQ_ALARM_DEFAULTS`:
|
|
89
|
+
|
|
90
|
+
| Alarm | Default on a DLQ | Rationale |
|
|
91
|
+
| --------------------------------------- | :-------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `approximateNumberOfMessagesVisible` | ✅ (> 0) | Any message on a DLQ indicates a delivery failure that needs investigation. |
|
|
93
|
+
| `approximateAgeOfOldestMessage` | ✅ (75% of retention) | Nothing consumes a DLQ, so "consumer falling behind" is meaningless — instead this is the last call to investigate before SQS silently deletes the message at `retentionPeriod`. The threshold scales with the queue's actual retention (75% of `retentionPeriod`). |
|
|
94
|
+
| `approximateNumberOfMessagesNotVisible` | ❌ | Nothing is normally in flight on a DLQ. Opt back in via `recommendedAlarms` if you have a reason to watch it. |
|
|
95
|
+
|
|
96
|
+
Every entry is individually overridable through the same `recommendedAlarms` API used for primary queues:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const ordersDlq = createQueueBuilder("dlq")
|
|
100
|
+
.recommendedAlarms({
|
|
101
|
+
approximateNumberOfMessagesVisible: { threshold: 5 }, // alert only once a small backlog builds
|
|
102
|
+
approximateAgeOfOldestMessage: false, // rely on the visible-messages alarm alone
|
|
103
|
+
})
|
|
104
|
+
.build(stack, "OrdersDlq");
|
|
105
|
+
```
|
|
20
106
|
|
|
21
107
|
## Secure Defaults
|
|
22
108
|
|
|
23
|
-
|
|
109
|
+
Every role applies the following defaults. Each can be overridden via the builder's fluent API.
|
|
24
110
|
|
|
25
111
|
| Property | Default | Rationale |
|
|
26
112
|
| ------------------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -28,12 +114,12 @@ Every [QueueProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s
|
|
|
28
114
|
| `encryption` | `QueueEncryption.SQS_MANAGED` | Encrypts at rest with the SQS-managed key (SSE-SQS). KMS encryption is opt-in via `.encryption(QueueEncryption.KMS)` + `.encryptionMasterKey(key)`. ([SQS data protection](https://docs.aws.amazon.com/AmazonSQS/latest/SQSDeveloperGuide/sqs-data-protection.html)) |
|
|
29
115
|
| `receiveMessageWaitTime` | `Duration.seconds(20)` | Enables [long polling](https://docs.aws.amazon.com/AmazonSQS/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html#sqs-long-polling) — fewer empty receives, lower cost, lower latency. 20s is the SQS maximum. |
|
|
30
116
|
|
|
31
|
-
`visibilityTimeout` is intentionally not defaulted — it must match the longest consumer processing time, which is workload-specific. `retentionPeriod` is
|
|
117
|
+
`visibilityTimeout` is intentionally not defaulted — it must match the longest consumer processing time, which is workload-specific. `retentionPeriod` is left at CDK's default of 4 days on the primary roles (the dead-letter roles raise it to 14 days, see above).
|
|
32
118
|
|
|
33
|
-
The defaults are exported as `QUEUE_DEFAULTS` for visibility and testing:
|
|
119
|
+
The defaults are exported as `QUEUE_DEFAULTS` (shared) and `DLQ_QUEUE_DEFAULTS` (the dead-letter layer) for visibility and testing:
|
|
34
120
|
|
|
35
121
|
```ts
|
|
36
|
-
import { QUEUE_DEFAULTS } from "@composurecdk/sqs";
|
|
122
|
+
import { DLQ_QUEUE_DEFAULTS, QUEUE_DEFAULTS } from "@composurecdk/sqs";
|
|
37
123
|
```
|
|
38
124
|
|
|
39
125
|
### Overriding defaults
|
|
@@ -50,19 +136,19 @@ const queue = createQueueBuilder()
|
|
|
50
136
|
|
|
51
137
|
The builder creates [AWS-recommended CloudWatch alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS) by default. No alarm actions are configured — access alarms from the build result to add SNS topics or other actions.
|
|
52
138
|
|
|
139
|
+
On the primary roles (`"standard"`, `"fifo"`):
|
|
140
|
+
|
|
53
141
|
| Alarm | Metric | Default threshold | Rationale |
|
|
54
142
|
| --------------------------------------- | ---------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
143
|
| `approximateAgeOfOldestMessage` | `ApproximateAgeOfOldestMessage` (Max, 1 min) | > 300s (5 min) | Primary "consumer falling behind" signal. Conservative starting point — tune to your SLA and `retentionPeriod`. |
|
|
56
144
|
| `approximateNumberOfMessagesNotVisible` | `ApproximateNumberOfMessagesNotVisible` (Max, 1 min) | > 90,000 | 75% of the [120k in-flight messages](https://docs.aws.amazon.com/AmazonSQS/latest/SQSDeveloperGuide/quotas-messages.html#quotas-in-flight) per-queue quota. Proactive guardrail before receives are rejected. |
|
|
57
145
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
The third AWS-recommended SQS alarm, `ApproximateNumberOfMessagesVisible`, is not enabled by default — its useful threshold depends entirely on the application's processing capacity, and any generic value would be either noise or silence. Use `addAlarm` (see [Custom alarms](#custom-alarms)) to add it for workloads where you know the right threshold.
|
|
146
|
+
The third AWS-recommended SQS alarm, `ApproximateNumberOfMessagesVisible`, is not enabled by default on a primary queue — its useful threshold depends entirely on the application's processing capacity, and any generic value would be either noise or silence. Enable it explicitly via `recommendedAlarms` with your own threshold (enabling it without one throws at build). On the dead-letter roles it is on by default with threshold > 0 (see [DLQ alarms](#dlq-alarms)).
|
|
61
147
|
|
|
62
|
-
The defaults are exported as `QUEUE_ALARM_DEFAULTS` for visibility and testing:
|
|
148
|
+
The defaults are exported as `QUEUE_ALARM_DEFAULTS` (primary) and `DLQ_ALARM_DEFAULTS` (dead-letter) for visibility and testing:
|
|
63
149
|
|
|
64
150
|
```ts
|
|
65
|
-
import { QUEUE_ALARM_DEFAULTS } from "@composurecdk/sqs";
|
|
151
|
+
import { DLQ_ALARM_DEFAULTS, QUEUE_ALARM_DEFAULTS } from "@composurecdk/sqs";
|
|
66
152
|
```
|
|
67
153
|
|
|
68
154
|
### Customizing thresholds
|
|
@@ -95,7 +181,7 @@ builder.recommendedAlarms({ approximateNumberOfMessagesNotVisible: false });
|
|
|
95
181
|
|
|
96
182
|
### Custom alarms
|
|
97
183
|
|
|
98
|
-
Add custom alarms alongside the recommended ones via `addAlarm
|
|
184
|
+
Add custom alarms alongside the recommended ones via `addAlarm` (available in every role). The callback receives an `AlarmDefinitionBuilder` typed to `IQueue`, so the metric factory has access to the queue's properties.
|
|
99
185
|
|
|
100
186
|
```ts
|
|
101
187
|
import { Duration } from "aws-cdk-lib";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Fraction of a dead-letter queue's `retentionPeriod` at which the
|
|
4
|
+
* `approximateAgeOfOldestMessage` alarm fires by default. Messages older
|
|
5
|
+
* than this have sat unattended for most of their retention window and
|
|
6
|
+
* are approaching silent deletion by SQS — the alarm is the last call to
|
|
7
|
+
* investigate and redrive them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DLQ_AGE_ALARM_RETENTION_RATIO = 0.75;
|
|
10
|
+
/**
|
|
11
|
+
* AWS-recommended default alarm configuration for dead-letter queues
|
|
12
|
+
* built in a dead-letter role (`createQueueBuilder("dlq")` /
|
|
13
|
+
* `createQueueBuilder("fifo-dlq")`).
|
|
14
|
+
*
|
|
15
|
+
* The enabled set inverts relative to a primary queue:
|
|
16
|
+
*
|
|
17
|
+
* - `approximateNumberOfMessagesVisible` (> 0) is **on** — any message
|
|
18
|
+
* on a DLQ indicates a delivery failure that needs investigation.
|
|
19
|
+
* - `approximateAgeOfOldestMessage` is **on**, re-framed: nothing
|
|
20
|
+
* consumes a DLQ, so instead of "consumers falling behind" it fires
|
|
21
|
+
* when the oldest message has used {@link DLQ_AGE_ALARM_RETENTION_RATIO}
|
|
22
|
+
* of the queue's `retentionPeriod` — the threshold below is derived
|
|
23
|
+
* from the default 14-day retention, and the builder scales it to the
|
|
24
|
+
* actual retention period at build time.
|
|
25
|
+
* - `approximateNumberOfMessagesNotVisible` is **off** — nothing is
|
|
26
|
+
* normally in flight on a DLQ. The baseline (shared with
|
|
27
|
+
* {@link QUEUE_ALARM_DEFAULTS} via spread) applies if explicitly
|
|
28
|
+
* re-enabled.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
31
|
+
*/
|
|
32
|
+
export declare const DLQ_ALARM_DEFAULTS: {
|
|
33
|
+
approximateAgeOfOldestMessage: {
|
|
34
|
+
threshold: number;
|
|
35
|
+
evaluationPeriods: number;
|
|
36
|
+
datapointsToAlarm: number;
|
|
37
|
+
treatMissingData: TreatMissingData.NOT_BREACHING;
|
|
38
|
+
};
|
|
39
|
+
/** 0 — any message on a dead-letter queue is itself the alert. */
|
|
40
|
+
approximateNumberOfMessagesVisible: {
|
|
41
|
+
threshold: number;
|
|
42
|
+
evaluationPeriods: number;
|
|
43
|
+
datapointsToAlarm: number;
|
|
44
|
+
treatMissingData: TreatMissingData.NOT_BREACHING;
|
|
45
|
+
};
|
|
46
|
+
approximateNumberOfMessagesNotVisible: {
|
|
47
|
+
threshold: number;
|
|
48
|
+
evaluationPeriods: number;
|
|
49
|
+
datapointsToAlarm: number;
|
|
50
|
+
treatMissingData: TreatMissingData.NOT_BREACHING;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=dlq-alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlq-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/dlq-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAK9D;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;IAU7B,kEAAkE;;;;;;;;;;;;;CAOtC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DLQ_ALARM_DEFAULTS = exports.DLQ_AGE_ALARM_RETENTION_RATIO = void 0;
|
|
4
|
+
const aws_cloudwatch_1 = require("aws-cdk-lib/aws-cloudwatch");
|
|
5
|
+
const queue_alarm_defaults_js_1 = require("./queue-alarm-defaults.js");
|
|
6
|
+
const dlq_defaults_js_1 = require("./dlq-defaults.js");
|
|
7
|
+
/**
|
|
8
|
+
* Fraction of a dead-letter queue's `retentionPeriod` at which the
|
|
9
|
+
* `approximateAgeOfOldestMessage` alarm fires by default. Messages older
|
|
10
|
+
* than this have sat unattended for most of their retention window and
|
|
11
|
+
* are approaching silent deletion by SQS — the alarm is the last call to
|
|
12
|
+
* investigate and redrive them.
|
|
13
|
+
*/
|
|
14
|
+
exports.DLQ_AGE_ALARM_RETENTION_RATIO = 0.75;
|
|
15
|
+
/**
|
|
16
|
+
* AWS-recommended default alarm configuration for dead-letter queues
|
|
17
|
+
* built in a dead-letter role (`createQueueBuilder("dlq")` /
|
|
18
|
+
* `createQueueBuilder("fifo-dlq")`).
|
|
19
|
+
*
|
|
20
|
+
* The enabled set inverts relative to a primary queue:
|
|
21
|
+
*
|
|
22
|
+
* - `approximateNumberOfMessagesVisible` (> 0) is **on** — any message
|
|
23
|
+
* on a DLQ indicates a delivery failure that needs investigation.
|
|
24
|
+
* - `approximateAgeOfOldestMessage` is **on**, re-framed: nothing
|
|
25
|
+
* consumes a DLQ, so instead of "consumers falling behind" it fires
|
|
26
|
+
* when the oldest message has used {@link DLQ_AGE_ALARM_RETENTION_RATIO}
|
|
27
|
+
* of the queue's `retentionPeriod` — the threshold below is derived
|
|
28
|
+
* from the default 14-day retention, and the builder scales it to the
|
|
29
|
+
* actual retention period at build time.
|
|
30
|
+
* - `approximateNumberOfMessagesNotVisible` is **off** — nothing is
|
|
31
|
+
* normally in flight on a DLQ. The baseline (shared with
|
|
32
|
+
* {@link QUEUE_ALARM_DEFAULTS} via spread) applies if explicitly
|
|
33
|
+
* re-enabled.
|
|
34
|
+
*
|
|
35
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
36
|
+
*/
|
|
37
|
+
exports.DLQ_ALARM_DEFAULTS = {
|
|
38
|
+
...queue_alarm_defaults_js_1.QUEUE_ALARM_DEFAULTS,
|
|
39
|
+
approximateAgeOfOldestMessage: {
|
|
40
|
+
threshold: dlq_defaults_js_1.DLQ_QUEUE_DEFAULTS.retentionPeriod.toSeconds() * exports.DLQ_AGE_ALARM_RETENTION_RATIO,
|
|
41
|
+
evaluationPeriods: 1,
|
|
42
|
+
datapointsToAlarm: 1,
|
|
43
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
44
|
+
},
|
|
45
|
+
/** 0 — any message on a dead-letter queue is itself the alert. */
|
|
46
|
+
approximateNumberOfMessagesVisible: {
|
|
47
|
+
threshold: 0,
|
|
48
|
+
evaluationPeriods: 1,
|
|
49
|
+
datapointsToAlarm: 1,
|
|
50
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=dlq-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlq-alarm-defaults.js","sourceRoot":"","sources":["../../src/dlq-alarm-defaults.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAE9D,uEAAiE;AACjE,uDAAuD;AAEvD;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,IAAI,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,kBAAkB,GAAG;IAChC,GAAG,8CAAoB;IAEvB,6BAA6B,EAAE;QAC7B,SAAS,EAAE,oCAAkB,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,qCAA6B;QACzF,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;IAED,kEAAkE;IAClE,kCAAkC,EAAE;QAClC,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;CAC2B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
/**
|
|
3
|
+
* AWS-recommended defaults layered on top of {@link QUEUE_DEFAULTS} for
|
|
4
|
+
* queues built in a dead-letter role (`createQueueBuilder("dlq")` /
|
|
5
|
+
* `createQueueBuilder("fifo-dlq")`).
|
|
6
|
+
*/
|
|
7
|
+
export declare const DLQ_QUEUE_DEFAULTS: {
|
|
8
|
+
/**
|
|
9
|
+
* 14 days — the SQS maximum. A dead-letter queue exists to give
|
|
10
|
+
* operators a window to investigate and redrive failed messages, so
|
|
11
|
+
* maximizing that window is the point; the 4-day CDK default would let
|
|
12
|
+
* messages expire before anyone notices them. The Well-Architected
|
|
13
|
+
* Reliability Pillar calls for retaining failed messages long enough
|
|
14
|
+
* to analyse and reprocess them.
|
|
15
|
+
* @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
|
|
16
|
+
*/
|
|
17
|
+
retentionPeriod: Duration;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=dlq-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlq-defaults.d.ts","sourceRoot":"","sources":["../../src/dlq-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;;;;OAQG;;CAE0B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DLQ_QUEUE_DEFAULTS = void 0;
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
/**
|
|
6
|
+
* AWS-recommended defaults layered on top of {@link QUEUE_DEFAULTS} for
|
|
7
|
+
* queues built in a dead-letter role (`createQueueBuilder("dlq")` /
|
|
8
|
+
* `createQueueBuilder("fifo-dlq")`).
|
|
9
|
+
*/
|
|
10
|
+
exports.DLQ_QUEUE_DEFAULTS = {
|
|
11
|
+
/**
|
|
12
|
+
* 14 days — the SQS maximum. A dead-letter queue exists to give
|
|
13
|
+
* operators a window to investigate and redrive failed messages, so
|
|
14
|
+
* maximizing that window is the point; the 4-day CDK default would let
|
|
15
|
+
* messages expire before anyone notices them. The Well-Architected
|
|
16
|
+
* Reliability Pillar calls for retaining failed messages long enough
|
|
17
|
+
* to analyse and reprocess them.
|
|
18
|
+
* @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
|
|
19
|
+
*/
|
|
20
|
+
retentionPeriod: aws_cdk_lib_1.Duration.days(14),
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=dlq-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlq-defaults.js","sourceRoot":"","sources":["../../src/dlq-defaults.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAGvC;;;;GAIG;AACU,QAAA,kBAAkB,GAAG;IAChC;;;;;;;;OAQG;IACH,eAAe,EAAE,sBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IGrantable } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import type { IQueue } from "aws-cdk-lib/aws-sqs";
|
|
3
|
+
import { type Grant, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Consumer-side grant helpers for an SQS queue. Pass one to a grantee builder's
|
|
6
|
+
* `grant(...)` — e.g.
|
|
7
|
+
* `role.grant(queueGrants.consume(ref("queue", (r) => r.queue)))`.
|
|
8
|
+
*
|
|
9
|
+
* Each delegates to the queue's native `grant*` method. See ADR-0013.
|
|
10
|
+
*/
|
|
11
|
+
export declare const queueGrants: {
|
|
12
|
+
/** Receive and delete messages (`sqs:ReceiveMessage`, `DeleteMessage`, …). */
|
|
13
|
+
consume: (queue: Resolvable<IQueue>) => Grant<IGrantable>;
|
|
14
|
+
/** Send messages (`sqs:SendMessage`, `GetQueueAttributes`, …). */
|
|
15
|
+
send: (queue: Resolvable<IQueue>) => Grant<IGrantable>;
|
|
16
|
+
/** Purge the queue (`sqs:PurgeQueue`). */
|
|
17
|
+
purge: (queue: Resolvable<IQueue>) => Grant<IGrantable>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,KAAK,EAAY,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQ3E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;IACtB,8EAA8E;qBAXtE,UAAU,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;IAe9C,kEAAkE;kBAf1D,UAAU,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;IAmB9C,0CAA0C;mBAnBlC,UAAU,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,UAAU,CAAC;CAuB/C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queueGrants = void 0;
|
|
4
|
+
const core_1 = require("@composurecdk/core");
|
|
5
|
+
/** Wraps one of {@link IQueue}'s native grant methods as a capability helper. */
|
|
6
|
+
const capability = (apply) => (queue) => (0, core_1.grantVia)(queue, apply);
|
|
7
|
+
/**
|
|
8
|
+
* Consumer-side grant helpers for an SQS queue. Pass one to a grantee builder's
|
|
9
|
+
* `grant(...)` — e.g.
|
|
10
|
+
* `role.grant(queueGrants.consume(ref("queue", (r) => r.queue)))`.
|
|
11
|
+
*
|
|
12
|
+
* Each delegates to the queue's native `grant*` method. See ADR-0013.
|
|
13
|
+
*/
|
|
14
|
+
exports.queueGrants = {
|
|
15
|
+
/** Receive and delete messages (`sqs:ReceiveMessage`, `DeleteMessage`, …). */
|
|
16
|
+
consume: capability((queue, grantee) => {
|
|
17
|
+
queue.grantConsumeMessages(grantee);
|
|
18
|
+
}),
|
|
19
|
+
/** Send messages (`sqs:SendMessage`, `GetQueueAttributes`, …). */
|
|
20
|
+
send: capability((queue, grantee) => {
|
|
21
|
+
queue.grantSendMessages(grantee);
|
|
22
|
+
}),
|
|
23
|
+
/** Purge the queue (`sqs:PurgeQueue`). */
|
|
24
|
+
purge: capability((queue, grantee) => {
|
|
25
|
+
queue.grantPurge(grantee);
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/grants.ts"],"names":[],"mappings":";;;AAEA,6CAA2E;AAE3E,iFAAiF;AACjF,MAAM,UAAU,GACd,CAAC,KAAmD,EAAE,EAAE,CACxD,CAAC,KAAyB,EAAqB,EAAE,CAC/C,IAAA,eAAQ,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAE3B;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,8EAA8E;IAC9E,OAAO,EAAE,UAAU,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACrC,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,kEAAkE;IAClE,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAClC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC;IACF,0CAA0C;IAC1C,KAAK,EAAE,UAAU,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACnC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC;CACH,CAAC"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export { createQueueBuilder, type IQueueBuilder, type
|
|
1
|
+
export { createQueueBuilder, type IQueueBuilder, type QueueBuilderResult, } from "./queue-builder.js";
|
|
2
|
+
export { queueGrants } from "./grants.js";
|
|
3
|
+
export { type QueueRole } from "./queue-role.js";
|
|
4
|
+
export { type FifoQueueName, type QueueBuilderProps, type FifoQueueBuilderProps, type DlqQueueBuilderProps, type FifoDlqQueueBuilderProps, type QueueBuilderPropsByRole, } from "./queue-props.js";
|
|
2
5
|
export { QUEUE_DEFAULTS } from "./defaults.js";
|
|
6
|
+
export { DLQ_QUEUE_DEFAULTS } from "./dlq-defaults.js";
|
|
3
7
|
export { type QueueAlarmConfig } from "./queue-alarm-config.js";
|
|
4
8
|
export { QUEUE_ALARM_DEFAULTS } from "./queue-alarm-defaults.js";
|
|
9
|
+
export { DLQ_ALARM_DEFAULTS } from "./dlq-alarm-defaults.js";
|
|
5
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QUEUE_ALARM_DEFAULTS = exports.QUEUE_DEFAULTS = exports.createQueueBuilder = void 0;
|
|
3
|
+
exports.DLQ_ALARM_DEFAULTS = exports.QUEUE_ALARM_DEFAULTS = exports.DLQ_QUEUE_DEFAULTS = exports.QUEUE_DEFAULTS = exports.queueGrants = exports.createQueueBuilder = void 0;
|
|
4
4
|
var queue_builder_js_1 = require("./queue-builder.js");
|
|
5
5
|
Object.defineProperty(exports, "createQueueBuilder", { enumerable: true, get: function () { return queue_builder_js_1.createQueueBuilder; } });
|
|
6
|
+
var grants_js_1 = require("./grants.js");
|
|
7
|
+
Object.defineProperty(exports, "queueGrants", { enumerable: true, get: function () { return grants_js_1.queueGrants; } });
|
|
6
8
|
var defaults_js_1 = require("./defaults.js");
|
|
7
9
|
Object.defineProperty(exports, "QUEUE_DEFAULTS", { enumerable: true, get: function () { return defaults_js_1.QUEUE_DEFAULTS; } });
|
|
10
|
+
var dlq_defaults_js_1 = require("./dlq-defaults.js");
|
|
11
|
+
Object.defineProperty(exports, "DLQ_QUEUE_DEFAULTS", { enumerable: true, get: function () { return dlq_defaults_js_1.DLQ_QUEUE_DEFAULTS; } });
|
|
8
12
|
var queue_alarm_defaults_js_1 = require("./queue-alarm-defaults.js");
|
|
9
13
|
Object.defineProperty(exports, "QUEUE_ALARM_DEFAULTS", { enumerable: true, get: function () { return queue_alarm_defaults_js_1.QUEUE_ALARM_DEFAULTS; } });
|
|
14
|
+
var dlq_alarm_defaults_js_1 = require("./dlq-alarm-defaults.js");
|
|
15
|
+
Object.defineProperty(exports, "DLQ_ALARM_DEFAULTS", { enumerable: true, get: function () { return dlq_alarm_defaults_js_1.DLQ_ALARM_DEFAULTS; } });
|
|
10
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAI4B;AAH1B,sHAAA,kBAAkB,OAAA;AAIpB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AAepB,6CAA+C;AAAtC,6GAAA,cAAc,OAAA;AACvB,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA;AAE3B,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
2
|
/**
|
|
3
3
|
* Controls which recommended alarms are created for an SQS queue.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Which alarms are enabled by default — and their thresholds — depends
|
|
5
|
+
* on the queue's {@link QueueRole}: the primary roles (`"standard"`,
|
|
6
|
+
* `"fifo"`) and the dead-letter roles (`"dlq"`, `"fifo-dlq"`) invert
|
|
7
|
+
* which signals matter. Set an individual alarm to `false` to disable
|
|
8
|
+
* it, or provide an {@link AlarmConfig} to enable it (if off by
|
|
9
|
+
* default) or tune its thresholds (if on by default).
|
|
7
10
|
*
|
|
8
11
|
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
9
12
|
*/
|
|
@@ -16,15 +19,16 @@ export interface QueueAlarmConfig {
|
|
|
16
19
|
enabled?: boolean;
|
|
17
20
|
/**
|
|
18
21
|
* Alarm when the oldest unprocessed message in the queue has been
|
|
19
|
-
* waiting longer than the configured threshold.
|
|
20
|
-
*
|
|
22
|
+
* waiting longer than the configured threshold.
|
|
23
|
+
*
|
|
24
|
+
* On a primary queue this is the primary signal that consumers are
|
|
25
|
+
* falling behind (default threshold: > 300 seconds). On a dead-letter
|
|
26
|
+
* queue it signals messages approaching the end of the queue's
|
|
27
|
+
* `retentionPeriod` unattended (default threshold: 75% of the
|
|
28
|
+
* retention period — see {@link DLQ_ALARM_DEFAULTS}).
|
|
21
29
|
*
|
|
22
30
|
* Metric: `AWS/SQS ApproximateAgeOfOldestMessage`, statistic Maximum,
|
|
23
31
|
* period 1 minute.
|
|
24
|
-
* Default threshold: > 300 seconds (5 minutes).
|
|
25
|
-
*
|
|
26
|
-
* The default is conservative and should be tuned to the queue's
|
|
27
|
-
* SLA and `retentionPeriod`.
|
|
28
32
|
*
|
|
29
33
|
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
30
34
|
*/
|
|
@@ -34,13 +38,45 @@ export interface QueueAlarmConfig {
|
|
|
34
38
|
* messages approaches the SQS quota of 120,000 per queue. A breach
|
|
35
39
|
* means new messages will start being rejected.
|
|
36
40
|
*
|
|
41
|
+
* Enabled by default on primary queues (threshold: > 90,000 — 75% of
|
|
42
|
+
* the quota). Disabled by default on dead-letter queues, where nothing
|
|
43
|
+
* is normally in flight.
|
|
44
|
+
*
|
|
37
45
|
* Metric: `AWS/SQS ApproximateNumberOfMessagesNotVisible`, statistic
|
|
38
46
|
* Maximum, period 1 minute.
|
|
39
|
-
* Default threshold: > 90,000 (75% of the in-flight quota).
|
|
40
47
|
*
|
|
41
|
-
* @see https://docs.aws.amazon.com/
|
|
48
|
+
* @see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html#quotas-in-flight
|
|
42
49
|
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
43
50
|
*/
|
|
44
51
|
approximateNumberOfMessagesNotVisible?: AlarmConfig | false;
|
|
52
|
+
/**
|
|
53
|
+
* Alarm when the queue has visible (available-to-receive) messages
|
|
54
|
+
* above the threshold.
|
|
55
|
+
*
|
|
56
|
+
* Disabled by default on a primary queue — messages waiting to be
|
|
57
|
+
* consumed are the normal state, and no generic threshold suits every
|
|
58
|
+
* workload's processing capacity. Enable it explicitly with a
|
|
59
|
+
* threshold sized to your consumers; enabling it on a primary queue
|
|
60
|
+
* without a threshold throws at build.
|
|
61
|
+
*
|
|
62
|
+
* Enabled by default on a dead-letter queue, where any message present
|
|
63
|
+
* is itself the alert (default threshold: > 0). See
|
|
64
|
+
* {@link DLQ_ALARM_DEFAULTS}.
|
|
65
|
+
*
|
|
66
|
+
* Metric: `AWS/SQS ApproximateNumberOfMessagesVisible`, statistic
|
|
67
|
+
* Maximum, period 1 minute.
|
|
68
|
+
*
|
|
69
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
70
|
+
*/
|
|
71
|
+
approximateNumberOfMessagesVisible?: AlarmConfig | false;
|
|
45
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Keys of the recommended SQS alarms a queue builder can create —
|
|
75
|
+
* every {@link QueueAlarmConfig} entry except the `enabled` master
|
|
76
|
+
* switch. Shared between the primary-queue defaults
|
|
77
|
+
* ({@link QUEUE_ALARM_DEFAULTS}) and the dead-letter-queue defaults
|
|
78
|
+
* ({@link DLQ_ALARM_DEFAULTS}) so every builder resolves the same
|
|
79
|
+
* config shape.
|
|
80
|
+
*/
|
|
81
|
+
export type QueueAlarmKey = Exclude<keyof QueueAlarmConfig, "enabled">;
|
|
46
82
|
//# sourceMappingURL=queue-alarm-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-alarm-config.d.ts","sourceRoot":"","sources":["../../src/queue-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"queue-alarm-config.d.ts","sourceRoot":"","sources":["../../src/queue-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,6BAA6B,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAEpD;;;;;;;;;;;;;;OAcG;IACH,qCAAqC,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAE5D;;;;;;;;;;;;;;;;;;OAkBG;IACH,kCAAkC,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAC1D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,gBAAgB,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -1,18 +1,53 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
1
2
|
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
-
|
|
3
|
-
enabled: true;
|
|
4
|
-
approximateAgeOfOldestMessage: AlarmConfigDefaults;
|
|
5
|
-
approximateNumberOfMessagesNotVisible: AlarmConfigDefaults;
|
|
6
|
-
}
|
|
3
|
+
import type { QueueAlarmKey } from "./queue-alarm-config.js";
|
|
7
4
|
/**
|
|
8
|
-
*
|
|
5
|
+
* Shape of a recommended-alarm default set: an {@link AlarmConfigDefaults}
|
|
6
|
+
* baseline per recommended SQS alarm. Partial — an alarm with no entry
|
|
7
|
+
* has no generic default and requires an explicit threshold when
|
|
8
|
+
* enabled. Implemented by {@link QUEUE_ALARM_DEFAULTS} (primary queues)
|
|
9
|
+
* and {@link DLQ_ALARM_DEFAULTS} (dead-letter queues).
|
|
10
|
+
*/
|
|
11
|
+
export type QueueAlarmDefaults = Partial<Record<QueueAlarmKey, AlarmConfigDefaults>>;
|
|
12
|
+
/**
|
|
13
|
+
* AWS-recommended default alarm configuration for primary
|
|
14
|
+
* (consumer-fed) SQS queues, standard and FIFO alike — since November
|
|
15
|
+
* 2024 FIFO queues share the standard 120,000 in-flight quota, so the
|
|
16
|
+
* same thresholds apply.
|
|
9
17
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
18
|
+
* These are threshold baselines only — which alarms are *enabled* by
|
|
19
|
+
* default differs per builder: dead-letter queues invert the set (see
|
|
20
|
+
* {@link DLQ_ALARM_DEFAULTS}) because any message on a DLQ is itself an
|
|
21
|
+
* alert, whereas a primary queue with messages is normal. There is no
|
|
22
|
+
* entry for `approximateNumberOfMessagesVisible`: no generic threshold
|
|
23
|
+
* suits a primary queue, so enabling it requires an explicit threshold.
|
|
13
24
|
*
|
|
14
25
|
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SQS
|
|
26
|
+
* @see https://aws.amazon.com/about-aws/whats-new/2024/11/amazon-sqs-increases-in-flight-limit-fifo-queues/
|
|
15
27
|
*/
|
|
16
|
-
export declare const QUEUE_ALARM_DEFAULTS:
|
|
17
|
-
|
|
28
|
+
export declare const QUEUE_ALARM_DEFAULTS: {
|
|
29
|
+
/**
|
|
30
|
+
* 5 minutes. Conservative starting point for a "consumer falling
|
|
31
|
+
* behind" alarm. The right value depends on the workload's SLA and
|
|
32
|
+
* `retentionPeriod`; tune via `recommendedAlarms`.
|
|
33
|
+
*/
|
|
34
|
+
approximateAgeOfOldestMessage: {
|
|
35
|
+
threshold: number;
|
|
36
|
+
evaluationPeriods: number;
|
|
37
|
+
datapointsToAlarm: number;
|
|
38
|
+
treatMissingData: TreatMissingData.NOT_BREACHING;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 90,000 — 75% of the SQS 120,000 in-flight message quota. Proactive
|
|
42
|
+
* guardrail; a breach means the queue is approaching the point where
|
|
43
|
+
* new messages will be rejected.
|
|
44
|
+
* @see https://docs.aws.amazon.com/AmazonSQS/latest/SQSDeveloperGuide/quotas-messages.html#quotas-in-flight
|
|
45
|
+
*/
|
|
46
|
+
approximateNumberOfMessagesNotVisible: {
|
|
47
|
+
threshold: number;
|
|
48
|
+
evaluationPeriods: number;
|
|
49
|
+
datapointsToAlarm: number;
|
|
50
|
+
treatMissingData: TreatMissingData.NOT_BREACHING;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
18
53
|
//# sourceMappingURL=queue-alarm-defaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/queue-alarm-defaults.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/queue-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAErF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;OAIG;;;;;;;IAQH;;;;;OAKG;;;;;;;CAOyB,CAAC"}
|