@composurecdk/sns 0.7.0 → 0.8.1
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 +57 -10
- package/dist/commonjs/defaults.d.ts.map +1 -0
- package/dist/commonjs/defaults.js +17 -0
- package/dist/commonjs/defaults.js.map +1 -0
- package/dist/{index.d.ts → commonjs/index.d.ts} +1 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +14 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/{subscription-builder.d.ts → commonjs/subscription-builder.d.ts} +36 -32
- package/dist/commonjs/subscription-builder.d.ts.map +1 -0
- package/dist/commonjs/subscription-builder.js +57 -0
- package/dist/commonjs/subscription-builder.js.map +1 -0
- package/dist/commonjs/subscription-defaults.d.ts +60 -0
- package/dist/commonjs/subscription-defaults.d.ts.map +1 -0
- package/dist/commonjs/subscription-defaults.js +78 -0
- package/dist/commonjs/subscription-defaults.js.map +1 -0
- package/dist/commonjs/topic-alarm-config.d.ts.map +1 -0
- package/dist/commonjs/topic-alarm-config.js +3 -0
- package/dist/commonjs/topic-alarm-config.js.map +1 -0
- package/dist/commonjs/topic-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/topic-alarm-defaults.js +41 -0
- package/dist/commonjs/topic-alarm-defaults.js.map +1 -0
- package/dist/commonjs/topic-alarms.d.ts.map +1 -0
- package/dist/commonjs/topic-alarms.js +108 -0
- package/dist/commonjs/topic-alarms.js.map +1 -0
- package/dist/commonjs/topic-builder.d.ts.map +1 -0
- package/dist/commonjs/topic-builder.js +97 -0
- package/dist/commonjs/topic-builder.js.map +1 -0
- package/dist/esm/defaults.d.ts +8 -0
- package/dist/esm/defaults.d.ts.map +1 -0
- package/dist/esm/defaults.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/{index.js → esm/index.js} +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/subscription-builder.d.ts +104 -0
- package/dist/esm/subscription-builder.d.ts.map +1 -0
- package/dist/esm/subscription-builder.js +54 -0
- package/dist/esm/subscription-builder.js.map +1 -0
- package/dist/esm/subscription-defaults.d.ts +60 -0
- package/dist/esm/subscription-defaults.d.ts.map +1 -0
- package/dist/esm/subscription-defaults.js +74 -0
- package/dist/esm/subscription-defaults.js.map +1 -0
- package/dist/esm/topic-alarm-config.d.ts +67 -0
- package/dist/esm/topic-alarm-config.d.ts.map +1 -0
- package/dist/esm/topic-alarm-config.js.map +1 -0
- package/dist/esm/topic-alarm-defaults.d.ts +16 -0
- package/dist/esm/topic-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/topic-alarm-defaults.js.map +1 -0
- package/dist/esm/topic-alarms.d.ts +26 -0
- package/dist/esm/topic-alarms.d.ts.map +1 -0
- package/dist/esm/topic-alarms.js.map +1 -0
- package/dist/esm/topic-builder.d.ts +136 -0
- package/dist/esm/topic-builder.d.ts.map +1 -0
- package/dist/{topic-builder.js → esm/topic-builder.js} +2 -1
- package/dist/esm/topic-builder.js.map +1 -0
- package/package.json +36 -18
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/subscription-builder.d.ts.map +0 -1
- package/dist/subscription-builder.js +0 -58
- package/dist/subscription-builder.js.map +0 -1
- package/dist/topic-alarm-config.d.ts.map +0 -1
- package/dist/topic-alarm-config.js.map +0 -1
- package/dist/topic-alarm-defaults.d.ts.map +0 -1
- package/dist/topic-alarm-defaults.js.map +0 -1
- package/dist/topic-alarms.d.ts.map +0 -1
- package/dist/topic-alarms.js.map +0 -1
- package/dist/topic-builder.d.ts.map +0 -1
- package/dist/topic-builder.js.map +0 -1
- /package/dist/{defaults.d.ts → commonjs/defaults.d.ts} +0 -0
- /package/dist/{topic-alarm-config.d.ts → commonjs/topic-alarm-config.d.ts} +0 -0
- /package/dist/{topic-alarm-defaults.d.ts → commonjs/topic-alarm-defaults.d.ts} +0 -0
- /package/dist/{topic-alarms.d.ts → commonjs/topic-alarms.d.ts} +0 -0
- /package/dist/{topic-builder.d.ts → commonjs/topic-builder.d.ts} +0 -0
- /package/dist/{defaults.js → esm/defaults.js} +0 -0
- /package/dist/{topic-alarm-config.js → esm/topic-alarm-config.js} +0 -0
- /package/dist/{topic-alarm-defaults.js → esm/topic-alarm-defaults.js} +0 -0
- /package/dist/{topic-alarms.js → esm/topic-alarms.js} +0 -0
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ The builder creates [AWS-recommended CloudWatch alarms](https://docs.aws.amazon.
|
|
|
50
50
|
| `numberOfNotificationsRedrivenToDlq` | NumberOfNotificationsRedrivenToDlq (Sum, 1 min) | > 0 | Always[^dlq] |
|
|
51
51
|
| `numberOfNotificationsFailedToRedriveToDlq` | NumberOfNotificationsFailedToRedriveToDlq (Sum, 1 min) | > 0 | Always[^dlq] |
|
|
52
52
|
|
|
53
|
-
[^dlq]: Metric only emits when a subscription on the topic has a dead-letter queue attached and SNS attempts redrive. `TreatMissingData` defaults to `notBreaching`, so the alarm stays quiet on topics without DLQs. Attach a DLQ
|
|
53
|
+
[^dlq]: Metric only emits when a subscription on the topic has a dead-letter queue attached and SNS attempts redrive. `TreatMissingData` defaults to `notBreaching`, so the alarm stays quiet on topics without DLQs. Attach a DLQ on the `ITopicSubscription` itself (e.g. `new LambdaSubscription(fn, { deadLetterQueue: dlq })`) — see [SNS DLQ docs](https://docs.aws.amazon.com/sns/latest/dg/sns-dead-letter-queues.html).
|
|
54
54
|
|
|
55
55
|
The defaults are exported as `TOPIC_ALARM_DEFAULTS` for visibility and testing:
|
|
56
56
|
|
|
@@ -167,31 +167,47 @@ const system = compose(
|
|
|
167
167
|
|
|
168
168
|
## Subscription Builder
|
|
169
169
|
|
|
170
|
+
Use `createSubscriptionBuilder` when subscribing to a **foreign** topic — one that is not built in the same `compose` system (for example, a topic owned by another stack or account). When the topic and its subscriptions are declared together, prefer [`TopicBuilder.addSubscription`](#adding-subscriptions-to-a-topic) instead.
|
|
171
|
+
|
|
170
172
|
```ts
|
|
171
173
|
import { createSubscriptionBuilder } from "@composurecdk/sns";
|
|
172
|
-
import {
|
|
174
|
+
import { EmailSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
173
175
|
|
|
174
176
|
const emailAlerts = createSubscriptionBuilder()
|
|
175
177
|
.topic(budgetTopic)
|
|
176
|
-
.
|
|
177
|
-
.endpoint("ops@example.com")
|
|
178
|
+
.subscription(new EmailSubscription("ops@example.com"))
|
|
178
179
|
.build(stack, "BudgetEmailSubscription");
|
|
179
180
|
```
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
The builder accepts any CDK [`ITopicSubscription`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sns.ITopicSubscription.html) (e.g. `EmailSubscription`, `LambdaSubscription`, `SqsSubscription`) and binds it via `ITopicSubscription.bind(topic)` — the same path CDK uses for `topic.addSubscription(...)`, so endpoint-specific wire-up (Lambda invoke permission, SQS queue policy, KMS decrypt grant) happens automatically. Subscription-specific options — dead-letter queue, filter policy, raw message delivery — are configured on the `ITopicSubscription` itself, matching CDK's own API:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { LambdaSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
186
|
+
|
|
187
|
+
createSubscriptionBuilder()
|
|
188
|
+
.topic(orderEventsTopic)
|
|
189
|
+
.subscription(
|
|
190
|
+
new LambdaSubscription(handler, {
|
|
191
|
+
deadLetterQueue: dlq,
|
|
192
|
+
filterPolicy: { severity: SubscriptionFilter.stringFilter({ allowlist: ["HIGH"] }) },
|
|
193
|
+
}),
|
|
194
|
+
)
|
|
195
|
+
.build(stack, "OrderEventsHandler");
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Both `.topic(...)` and `.subscription(...)` accept a `Ref`, so the builder composes cleanly with a `TopicBuilder` — or with any other component that produces the endpoint resource:
|
|
182
199
|
|
|
183
200
|
```ts
|
|
184
201
|
import { compose, ref } from "@composurecdk/core";
|
|
185
202
|
import { createTopicBuilder, createSubscriptionBuilder } from "@composurecdk/sns";
|
|
186
|
-
import {
|
|
203
|
+
import { EmailSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
187
204
|
|
|
188
205
|
const system = compose(
|
|
189
206
|
{
|
|
190
207
|
budget: createTopicBuilder().topicName("budget-alerts"),
|
|
191
208
|
email: createSubscriptionBuilder()
|
|
192
209
|
.topic(ref("budget", (r) => r.topic))
|
|
193
|
-
.
|
|
194
|
-
.endpoint("ops@example.com"),
|
|
210
|
+
.subscription(new EmailSubscription("ops@example.com")),
|
|
195
211
|
},
|
|
196
212
|
{ budget: [], email: ["budget"] },
|
|
197
213
|
);
|
|
@@ -199,11 +215,42 @@ const system = compose(
|
|
|
199
215
|
|
|
200
216
|
### Subscription reliability
|
|
201
217
|
|
|
202
|
-
Attaching a dead-letter queue is the primary reliability control for SNS subscriptions ([AWS Well-Architected — Reliability Pillar](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/welcome.html), [SNS DLQ docs](https://docs.aws.amazon.com/sns/latest/dg/sns-dead-letter-queues.html)). Pass a queue
|
|
218
|
+
Attaching a dead-letter queue is the primary reliability control for SNS subscriptions ([AWS Well-Architected — Reliability Pillar](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/welcome.html), [SNS DLQ docs](https://docs.aws.amazon.com/sns/latest/dg/sns-dead-letter-queues.html)). Pass a queue to the `ITopicSubscription` constructor (e.g. `new EmailSubscription("ops@example.com", { deadLetterQueue: dlq })`); the builder does not create a DLQ automatically because the queue resource needs to be caller-owned.
|
|
203
219
|
|
|
204
220
|
The CloudWatch metrics that surface delivery failures (`NumberOfNotificationsRedrivenToDlq`, `NumberOfNotificationsFailedToRedriveToDlq`) are topic-level, so the recommended alarms for them live on the `TopicBuilder` (see [Recommended Alarms](#recommended-alarms) above) and only report data once at least one subscription has a DLQ attached.
|
|
205
221
|
|
|
206
|
-
|
|
222
|
+
## Subscription Defaults
|
|
223
|
+
|
|
224
|
+
Both `createSubscriptionBuilder` and `TopicBuilder.addSubscription` apply per-protocol defaults to the `TopicSubscriptionConfig` returned by `ITopicSubscription.bind(topic)`. Defaults are gap-filling: anything the `ITopicSubscription` itself configured (via its constructor options) wins; defaults only apply where the bound config left a field unset.
|
|
225
|
+
|
|
226
|
+
| Protocol | Default | Rationale |
|
|
227
|
+
| ---------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
|
+
| `SQS` | `rawMessageDelivery: true` | Removes the SNS envelope so downstream SQS consumers see the publisher's payload as-is — fewer bytes, no parse step. The typical choice for SNS → SQS fan-out. |
|
|
229
|
+
| `FIREHOSE` | `rawMessageDelivery: true` | Stores records as the publisher sent them rather than wrapped in an SNS envelope. |
|
|
230
|
+
| `HTTP` | _(no default applied)_ | Emits a synth-time warning instead — plain HTTP delivery means messages and signed-confirmation tokens travel unencrypted. Prefer `SubscriptionProtocol.HTTPS`. ([SNS security best practices](https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html)) |
|
|
231
|
+
|
|
232
|
+
`LAMBDA` is intentionally absent — SNS does not support raw delivery to Lambda subscriptions; the handler always receives the SNS envelope. Other protocols (HTTPS, EMAIL, EMAIL_JSON, SMS, APPLICATION) receive no overrides.
|
|
233
|
+
|
|
234
|
+
These defaults are guided by [SNS raw message delivery](https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html) and the [AWS SNS security best practices](https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html).
|
|
235
|
+
|
|
236
|
+
The map is exported as `SUBSCRIPTION_DEFAULTS` for visibility and testing:
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { SUBSCRIPTION_DEFAULTS } from "@composurecdk/sns";
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Overriding a default
|
|
243
|
+
|
|
244
|
+
Any default is individually overridable through the `ITopicSubscription`'s own constructor options:
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { SqsSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
248
|
+
|
|
249
|
+
createSubscriptionBuilder()
|
|
250
|
+
.topic(orders)
|
|
251
|
+
.subscription(new SqsSubscription(queue, { rawMessageDelivery: false }))
|
|
252
|
+
.build(stack, "OrdersToQueue");
|
|
253
|
+
```
|
|
207
254
|
|
|
208
255
|
## Examples
|
|
209
256
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,UAAU,CAO9C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOPIC_DEFAULTS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Secure, AWS-recommended defaults applied to every SNS topic built
|
|
6
|
+
* with {@link createTopicBuilder}. Each property can be individually
|
|
7
|
+
* overridden via the builder's fluent API.
|
|
8
|
+
*/
|
|
9
|
+
exports.TOPIC_DEFAULTS = {
|
|
10
|
+
/**
|
|
11
|
+
* Enforce TLS for all publish and subscribe operations on the topic.
|
|
12
|
+
* Adds a resource policy condition that denies requests not using SSL.
|
|
13
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html#enforce-encryption-data-in-transit
|
|
14
|
+
*/
|
|
15
|
+
enforceSSL: true,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,cAAc,GAAwB;IACjD;;;;OAIG;IACH,UAAU,EAAE,IAAI;CACjB,CAAC"}
|
|
@@ -3,4 +3,5 @@ export { TOPIC_DEFAULTS } from "./defaults.js";
|
|
|
3
3
|
export { type TopicAlarmConfig } from "./topic-alarm-config.js";
|
|
4
4
|
export { TOPIC_ALARM_DEFAULTS } from "./topic-alarm-defaults.js";
|
|
5
5
|
export { createSubscriptionBuilder, type ISubscriptionBuilder, type SubscriptionBuilderProps, type SubscriptionBuilderResult, } from "./subscription-builder.js";
|
|
6
|
+
export { SUBSCRIPTION_DEFAULTS, type SubscriptionDefaults } from "./subscription-defaults.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_DEFAULTS = exports.createSubscriptionBuilder = exports.TOPIC_ALARM_DEFAULTS = exports.TOPIC_DEFAULTS = exports.createTopicBuilder = void 0;
|
|
4
|
+
var topic_builder_js_1 = require("./topic-builder.js");
|
|
5
|
+
Object.defineProperty(exports, "createTopicBuilder", { enumerable: true, get: function () { return topic_builder_js_1.createTopicBuilder; } });
|
|
6
|
+
var defaults_js_1 = require("./defaults.js");
|
|
7
|
+
Object.defineProperty(exports, "TOPIC_DEFAULTS", { enumerable: true, get: function () { return defaults_js_1.TOPIC_DEFAULTS; } });
|
|
8
|
+
var topic_alarm_defaults_js_1 = require("./topic-alarm-defaults.js");
|
|
9
|
+
Object.defineProperty(exports, "TOPIC_ALARM_DEFAULTS", { enumerable: true, get: function () { return topic_alarm_defaults_js_1.TOPIC_ALARM_DEFAULTS; } });
|
|
10
|
+
var subscription_builder_js_1 = require("./subscription-builder.js");
|
|
11
|
+
Object.defineProperty(exports, "createSubscriptionBuilder", { enumerable: true, get: function () { return subscription_builder_js_1.createSubscriptionBuilder; } });
|
|
12
|
+
var subscription_defaults_js_1 = require("./subscription-defaults.js");
|
|
13
|
+
Object.defineProperty(exports, "SUBSCRIPTION_DEFAULTS", { enumerable: true, get: function () { return subscription_defaults_js_1.SUBSCRIPTION_DEFAULTS; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAK4B;AAJ1B,sHAAA,kBAAkB,OAAA;AAKpB,6CAA+C;AAAtC,6GAAA,cAAc,OAAA;AAEvB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,qEAKmC;AAJjC,oIAAA,yBAAyB,OAAA;AAK3B,uEAA8F;AAArF,iIAAA,qBAAqB,OAAA"}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import { type ITopic,
|
|
2
|
-
import type { IQueue } from "aws-cdk-lib/aws-sqs";
|
|
1
|
+
import { type ITopic, type ITopicSubscription, Subscription } from "aws-cdk-lib/aws-sns";
|
|
3
2
|
import { type IConstruct } from "constructs";
|
|
4
3
|
import { type IBuilder, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
4
|
/**
|
|
6
5
|
* Configuration properties for the SNS subscription builder.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* values
|
|
10
|
-
*
|
|
7
|
+
* Both fields are required at build time. Both accept {@link Resolvable}
|
|
8
|
+
* values so the subscription can be wired to other components via
|
|
9
|
+
* {@link ref} inside a {@link compose}d system.
|
|
11
10
|
*/
|
|
12
|
-
export interface SubscriptionBuilderProps
|
|
11
|
+
export interface SubscriptionBuilderProps {
|
|
13
12
|
/**
|
|
14
13
|
* The topic to subscribe to. Accepts a concrete {@link ITopic} or a
|
|
15
14
|
* {@link Ref} to another component's output (e.g. a `TopicBuilder`).
|
|
16
15
|
*/
|
|
17
16
|
topic: Resolvable<ITopic>;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* {@link Ref} to
|
|
18
|
+
* The subscription to attach. Accepts any CDK
|
|
19
|
+
* {@link ITopicSubscription} (e.g. `EmailSubscription`,
|
|
20
|
+
* `LambdaSubscription`, `SqsSubscription`) or a {@link Ref} to one.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @default - no dead letter queue
|
|
22
|
+
* The subscription is bound via `ITopicSubscription.bind(topic)`, which
|
|
23
|
+
* performs the endpoint-specific IAM/resource-policy wire-up (Lambda
|
|
24
|
+
* invoke permission, SQS queue policy, KMS decrypt grant, etc.).
|
|
25
|
+
* Subscription-specific options — dead-letter queue, filter policy, raw
|
|
26
|
+
* message delivery — are configured on the `ITopicSubscription` itself,
|
|
27
|
+
* matching CDK's own subscription API.
|
|
30
28
|
*/
|
|
31
|
-
|
|
29
|
+
subscription: Resolvable<ITopicSubscription>;
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* The build output of an {@link ISubscriptionBuilder}. Contains the CDK
|
|
@@ -41,28 +39,33 @@ export interface SubscriptionBuilderResult {
|
|
|
41
39
|
/**
|
|
42
40
|
* A fluent builder for configuring and creating an AWS SNS subscription.
|
|
43
41
|
*
|
|
44
|
-
* Each configuration property from the CDK {@link SubscriptionProps} is
|
|
45
|
-
* exposed as an overloaded method: call with a value to set it (returns the
|
|
46
|
-
* builder for chaining), or call with no arguments to read the current
|
|
47
|
-
* value.
|
|
48
|
-
*
|
|
49
42
|
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
50
43
|
* component in a {@link compose | composed system}. Its `topic` and
|
|
51
|
-
* `
|
|
52
|
-
*
|
|
44
|
+
* `subscription` properties accept {@link Resolvable} values so they can be
|
|
45
|
+
* supplied by another component's build output via {@link ref}.
|
|
46
|
+
*
|
|
47
|
+
* At build time, the configured `ITopicSubscription` is bound to the topic
|
|
48
|
+
* via `ITopicSubscription.bind(topic)` — the same path CDK uses for
|
|
49
|
+
* `topic.addSubscription(...)`. This ensures endpoint-specific wire-up
|
|
50
|
+
* (Lambda invoke permission, SQS queue policy, etc.) happens correctly.
|
|
53
51
|
*
|
|
54
52
|
* Recommended CloudWatch alarms related to subscription delivery (redrive
|
|
55
53
|
* to DLQ, failed redrive to DLQ) are emitted against topic-level metrics,
|
|
56
54
|
* so they live on {@link createTopicBuilder} rather than here.
|
|
57
55
|
*
|
|
56
|
+
* Use this builder when subscribing to a *foreign* topic — one not built in
|
|
57
|
+
* the same `compose` system. For the common case where a topic and its
|
|
58
|
+
* subscriptions are declared together, use `TopicBuilder.addSubscription`.
|
|
59
|
+
*
|
|
58
60
|
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sns.Subscription.html
|
|
59
61
|
*
|
|
60
62
|
* @example
|
|
61
63
|
* ```ts
|
|
64
|
+
* import { EmailSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
65
|
+
*
|
|
62
66
|
* const emailAlerts = createSubscriptionBuilder()
|
|
63
67
|
* .topic(ref("topic", (r: TopicBuilderResult) => r.topic))
|
|
64
|
-
* .
|
|
65
|
-
* .endpoint("ops@example.com");
|
|
68
|
+
* .subscription(new EmailSubscription("ops@example.com"));
|
|
66
69
|
* ```
|
|
67
70
|
*/
|
|
68
71
|
export type ISubscriptionBuilder = IBuilder<SubscriptionBuilderProps, SubscriptionBuilder>;
|
|
@@ -74,22 +77,23 @@ declare class SubscriptionBuilder implements Lifecycle<SubscriptionBuilderResult
|
|
|
74
77
|
* Creates a new {@link ISubscriptionBuilder} for configuring an AWS SNS
|
|
75
78
|
* subscription.
|
|
76
79
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
80
|
+
* The returned builder exposes `topic` and `subscription` as fluent
|
|
81
|
+
* setter/getters and implements {@link Lifecycle} for use with
|
|
82
|
+
* {@link compose}. Subscription-specific options (DLQ, filter policy, raw
|
|
83
|
+
* message delivery) are configured on the `ITopicSubscription` itself.
|
|
81
84
|
*
|
|
82
85
|
* @returns A fluent builder for an AWS SNS subscription.
|
|
83
86
|
*
|
|
84
87
|
* @example
|
|
85
88
|
* ```ts
|
|
89
|
+
* import { EmailSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
90
|
+
*
|
|
86
91
|
* const system = compose(
|
|
87
92
|
* {
|
|
88
93
|
* topic: createTopicBuilder().topicName("budget-alerts"),
|
|
89
94
|
* email: createSubscriptionBuilder()
|
|
90
95
|
* .topic(ref("topic", (r: TopicBuilderResult) => r.topic))
|
|
91
|
-
* .
|
|
92
|
-
* .endpoint("ops@example.com"),
|
|
96
|
+
* .subscription(new EmailSubscription("ops@example.com")),
|
|
93
97
|
* },
|
|
94
98
|
* { topic: [], email: ["topic"] },
|
|
95
99
|
* );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-builder.d.ts","sourceRoot":"","sources":["../../src/subscription-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,kBAAkB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,YAAY,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;IAC7D,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,wBAAwB,EAAE,mBAAmB,CAAC,CAAC;AAE3F,cAAM,mBAAoB,YAAW,SAAS,CAAC,yBAAyB,CAAC;IACvE,KAAK,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAM;IAE9C,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,yBAAyB;CA6B7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,yBAAyB,IAAI,oBAAoB,CAGhE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSubscriptionBuilder = createSubscriptionBuilder;
|
|
4
|
+
const aws_sns_1 = require("aws-cdk-lib/aws-sns");
|
|
5
|
+
const core_1 = require("@composurecdk/core");
|
|
6
|
+
const subscription_defaults_js_1 = require("./subscription-defaults.js");
|
|
7
|
+
class SubscriptionBuilder {
|
|
8
|
+
props = {};
|
|
9
|
+
build(scope, id, context = {}) {
|
|
10
|
+
const { topic, subscription } = this.props;
|
|
11
|
+
if (topic === undefined) {
|
|
12
|
+
throw new Error(`SubscriptionBuilder "${id}": topic is required. Call .topic(...) with an ITopic or a Ref before building.`);
|
|
13
|
+
}
|
|
14
|
+
if (subscription === undefined) {
|
|
15
|
+
throw new Error(`SubscriptionBuilder "${id}": subscription is required. Call .subscription(...) with an ITopicSubscription (e.g. EmailSubscription, LambdaSubscription, SqsSubscription) or a Ref before building.`);
|
|
16
|
+
}
|
|
17
|
+
const resolvedTopic = (0, core_1.resolve)(topic, context);
|
|
18
|
+
const resolvedSubscription = (0, core_1.resolve)(subscription, context);
|
|
19
|
+
const subscriptionConfig = (0, subscription_defaults_js_1.applySubscriptionDefaults)(scope, id, resolvedSubscription.bind(resolvedTopic));
|
|
20
|
+
const built = new aws_sns_1.Subscription(scope, id, {
|
|
21
|
+
topic: resolvedTopic,
|
|
22
|
+
...subscriptionConfig,
|
|
23
|
+
});
|
|
24
|
+
return { subscription: built };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new {@link ISubscriptionBuilder} for configuring an AWS SNS
|
|
29
|
+
* subscription.
|
|
30
|
+
*
|
|
31
|
+
* The returned builder exposes `topic` and `subscription` as fluent
|
|
32
|
+
* setter/getters and implements {@link Lifecycle} for use with
|
|
33
|
+
* {@link compose}. Subscription-specific options (DLQ, filter policy, raw
|
|
34
|
+
* message delivery) are configured on the `ITopicSubscription` itself.
|
|
35
|
+
*
|
|
36
|
+
* @returns A fluent builder for an AWS SNS subscription.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { EmailSubscription } from "aws-cdk-lib/aws-sns-subscriptions";
|
|
41
|
+
*
|
|
42
|
+
* const system = compose(
|
|
43
|
+
* {
|
|
44
|
+
* topic: createTopicBuilder().topicName("budget-alerts"),
|
|
45
|
+
* email: createSubscriptionBuilder()
|
|
46
|
+
* .topic(ref("topic", (r: TopicBuilderResult) => r.topic))
|
|
47
|
+
* .subscription(new EmailSubscription("ops@example.com")),
|
|
48
|
+
* },
|
|
49
|
+
* { topic: [], email: ["topic"] },
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
function createSubscriptionBuilder() {
|
|
54
|
+
// eslint-disable-next-line composurecdk/builder-must-be-tagged -- AWS::SNS::Subscription has no Tags property
|
|
55
|
+
return (0, core_1.Builder)(SubscriptionBuilder);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=subscription-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-builder.js","sourceRoot":"","sources":["../../src/subscription-builder.ts"],"names":[],"mappings":";;AAoJA,8DAGC;AAvJD,iDAAyF;AAEzF,6CAM4B;AAC5B,yEAAuE;AA2EvE,MAAM,mBAAmB;IACvB,KAAK,GAAsC,EAAE,CAAC;IAE9C,KAAK,CACH,KAAiB,EACjB,EAAU,EACV,UAAkC,EAAE;QAEpC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE3C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,wBAAwB,EAAE,iFAAiF,CAC5G,CAAC;QACJ,CAAC;QACD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,wBAAwB,EAAE,yKAAyK,CACpM,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAG,IAAA,cAAO,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,MAAM,oBAAoB,GAAG,IAAA,cAAO,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,kBAAkB,GAAG,IAAA,oDAAyB,EAClD,KAAK,EACL,EAAE,EACF,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CACzC,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,sBAAY,CAAC,KAAK,EAAE,EAAE,EAAE;YACxC,KAAK,EAAE,aAAa;YACpB,GAAG,kBAAkB;SACtB,CAAC,CAAC;QAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,yBAAyB;IACvC,8GAA8G;IAC9G,OAAO,IAAA,cAAO,EAAgD,mBAAmB,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SubscriptionProtocol, type TopicSubscriptionConfig } from "aws-cdk-lib/aws-sns";
|
|
2
|
+
import type { IConstruct } from "constructs";
|
|
3
|
+
/**
|
|
4
|
+
* Per-protocol overrides applied to a {@link TopicSubscriptionConfig}.
|
|
5
|
+
*
|
|
6
|
+
* Only fields relevant to delivery semantics are included; `protocol`,
|
|
7
|
+
* `endpoint`, `subscriberId`, etc. are determined by the
|
|
8
|
+
* {@link aws-cdk-lib.aws_sns.ITopicSubscription | ITopicSubscription} and
|
|
9
|
+
* are never defaulted here.
|
|
10
|
+
*/
|
|
11
|
+
export type SubscriptionDefaults = Pick<TopicSubscriptionConfig, "rawMessageDelivery">;
|
|
12
|
+
/**
|
|
13
|
+
* AWS-recommended defaults applied per `SubscriptionProtocol` when a
|
|
14
|
+
* subscription is bound through either `createSubscriptionBuilder` or
|
|
15
|
+
* `TopicBuilder.addSubscription`.
|
|
16
|
+
*
|
|
17
|
+
* Defaults are merged into the {@link TopicSubscriptionConfig} returned by
|
|
18
|
+
* `ITopicSubscription.bind(topic)`: any field the `ITopicSubscription`
|
|
19
|
+
* itself set to a defined value wins, and the default only fills the gap
|
|
20
|
+
* when the bound config left the field `undefined`. This keeps every
|
|
21
|
+
* default individually overridable through the `ITopicSubscription`
|
|
22
|
+
* constructor options.
|
|
23
|
+
*
|
|
24
|
+
* Only the protocols on which SNS actually supports raw message delivery
|
|
25
|
+
* (SQS and Firehose) receive a default — applying it elsewhere would
|
|
26
|
+
* trigger CDK's own raw-delivery validation at synth time. Lambda is
|
|
27
|
+
* intentionally absent: SNS does not support raw delivery to Lambda
|
|
28
|
+
* subscriptions, and Lambda handlers always receive the SNS envelope.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html
|
|
31
|
+
*/
|
|
32
|
+
export declare const SUBSCRIPTION_DEFAULTS: Partial<Record<SubscriptionProtocol, SubscriptionDefaults>>;
|
|
33
|
+
/**
|
|
34
|
+
* Merge {@link SUBSCRIPTION_DEFAULTS} into the result of
|
|
35
|
+
* `ITopicSubscription.bind(topic)` and emit transport-security warnings.
|
|
36
|
+
*
|
|
37
|
+
* Both `createSubscriptionBuilder` and `TopicBuilder.addSubscription`
|
|
38
|
+
* route through this helper so SNS subscriptions get the same defaults
|
|
39
|
+
* regardless of which builder created them.
|
|
40
|
+
*
|
|
41
|
+
* - Defaults are gap-filling: any field the `ITopicSubscription`
|
|
42
|
+
* explicitly set wins, and the default only applies when the bound
|
|
43
|
+
* config left the field `undefined`. Many `ITopicSubscription`
|
|
44
|
+
* implementations propagate `undefined` from their props, so a naive
|
|
45
|
+
* `{ ...defaults, ...config }` spread would clobber the defaults —
|
|
46
|
+
* this helper filters undefined entries before merging.
|
|
47
|
+
* - Emits a synth-time warning when subscribing over plain `HTTP` to
|
|
48
|
+
* nudge callers toward `HTTPS` for transport encryption. Other invalid
|
|
49
|
+
* protocol/option combinations (e.g. `rawMessageDelivery` on EMAIL)
|
|
50
|
+
* are surfaced by CDK's own `Subscription` validation.
|
|
51
|
+
*
|
|
52
|
+
* @param scope - The construct scope used to attach annotations.
|
|
53
|
+
* @param id - The subscription's logical id, used in warning text.
|
|
54
|
+
* @param config - The `TopicSubscriptionConfig` returned by
|
|
55
|
+
* `ITopicSubscription.bind(topic)`.
|
|
56
|
+
*
|
|
57
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html
|
|
58
|
+
*/
|
|
59
|
+
export declare function applySubscriptionDefaults(scope: IConstruct, id: string, config: TopicSubscriptionConfig): TopicSubscriptionConfig;
|
|
60
|
+
//# sourceMappingURL=subscription-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-defaults.d.ts","sourceRoot":"","sources":["../../src/subscription-defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAe7F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,uBAAuB,GAC9B,uBAAuB,CAgBzB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_DEFAULTS = void 0;
|
|
4
|
+
exports.applySubscriptionDefaults = applySubscriptionDefaults;
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
|
+
const aws_sns_1 = require("aws-cdk-lib/aws-sns");
|
|
7
|
+
/**
|
|
8
|
+
* AWS-recommended defaults applied per `SubscriptionProtocol` when a
|
|
9
|
+
* subscription is bound through either `createSubscriptionBuilder` or
|
|
10
|
+
* `TopicBuilder.addSubscription`.
|
|
11
|
+
*
|
|
12
|
+
* Defaults are merged into the {@link TopicSubscriptionConfig} returned by
|
|
13
|
+
* `ITopicSubscription.bind(topic)`: any field the `ITopicSubscription`
|
|
14
|
+
* itself set to a defined value wins, and the default only fills the gap
|
|
15
|
+
* when the bound config left the field `undefined`. This keeps every
|
|
16
|
+
* default individually overridable through the `ITopicSubscription`
|
|
17
|
+
* constructor options.
|
|
18
|
+
*
|
|
19
|
+
* Only the protocols on which SNS actually supports raw message delivery
|
|
20
|
+
* (SQS and Firehose) receive a default — applying it elsewhere would
|
|
21
|
+
* trigger CDK's own raw-delivery validation at synth time. Lambda is
|
|
22
|
+
* intentionally absent: SNS does not support raw delivery to Lambda
|
|
23
|
+
* subscriptions, and Lambda handlers always receive the SNS envelope.
|
|
24
|
+
*
|
|
25
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html
|
|
26
|
+
*/
|
|
27
|
+
exports.SUBSCRIPTION_DEFAULTS = {
|
|
28
|
+
/**
|
|
29
|
+
* Deliver raw payloads to SQS so downstream consumers don't have to
|
|
30
|
+
* unwrap the SNS envelope. Halves payload size and removes a parse step
|
|
31
|
+
* — the typical choice for SNS → SQS fan-out.
|
|
32
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html
|
|
33
|
+
*/
|
|
34
|
+
[aws_sns_1.SubscriptionProtocol.SQS]: { rawMessageDelivery: true },
|
|
35
|
+
/**
|
|
36
|
+
* Deliver raw payloads to Firehose so records are stored as the
|
|
37
|
+
* publisher sent them rather than wrapped in an SNS envelope.
|
|
38
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-large-payload-raw-message-delivery.html
|
|
39
|
+
*/
|
|
40
|
+
[aws_sns_1.SubscriptionProtocol.FIREHOSE]: { rawMessageDelivery: true },
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Merge {@link SUBSCRIPTION_DEFAULTS} into the result of
|
|
44
|
+
* `ITopicSubscription.bind(topic)` and emit transport-security warnings.
|
|
45
|
+
*
|
|
46
|
+
* Both `createSubscriptionBuilder` and `TopicBuilder.addSubscription`
|
|
47
|
+
* route through this helper so SNS subscriptions get the same defaults
|
|
48
|
+
* regardless of which builder created them.
|
|
49
|
+
*
|
|
50
|
+
* - Defaults are gap-filling: any field the `ITopicSubscription`
|
|
51
|
+
* explicitly set wins, and the default only applies when the bound
|
|
52
|
+
* config left the field `undefined`. Many `ITopicSubscription`
|
|
53
|
+
* implementations propagate `undefined` from their props, so a naive
|
|
54
|
+
* `{ ...defaults, ...config }` spread would clobber the defaults —
|
|
55
|
+
* this helper filters undefined entries before merging.
|
|
56
|
+
* - Emits a synth-time warning when subscribing over plain `HTTP` to
|
|
57
|
+
* nudge callers toward `HTTPS` for transport encryption. Other invalid
|
|
58
|
+
* protocol/option combinations (e.g. `rawMessageDelivery` on EMAIL)
|
|
59
|
+
* are surfaced by CDK's own `Subscription` validation.
|
|
60
|
+
*
|
|
61
|
+
* @param scope - The construct scope used to attach annotations.
|
|
62
|
+
* @param id - The subscription's logical id, used in warning text.
|
|
63
|
+
* @param config - The `TopicSubscriptionConfig` returned by
|
|
64
|
+
* `ITopicSubscription.bind(topic)`.
|
|
65
|
+
*
|
|
66
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html
|
|
67
|
+
*/
|
|
68
|
+
function applySubscriptionDefaults(scope, id, config) {
|
|
69
|
+
const protocolDefaults = exports.SUBSCRIPTION_DEFAULTS[config.protocol] ?? {};
|
|
70
|
+
const definedConfig = Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined));
|
|
71
|
+
const merged = { ...protocolDefaults, ...definedConfig };
|
|
72
|
+
if (merged.protocol === aws_sns_1.SubscriptionProtocol.HTTP) {
|
|
73
|
+
aws_cdk_lib_1.Annotations.of(scope).addWarningV2("@composurecdk/sns:http-subscription-insecure", `SNS subscription "${id}": delivering over plain HTTP — messages and any signed-confirmation tokens travel unencrypted. ` +
|
|
74
|
+
`Prefer SubscriptionProtocol.HTTPS for transport encryption.`);
|
|
75
|
+
}
|
|
76
|
+
return merged;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=subscription-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-defaults.js","sourceRoot":"","sources":["../../src/subscription-defaults.ts"],"names":[],"mappings":";;;AA6EA,8DAoBC;AAjGD,6CAA0C;AAC1C,iDAAyF;AAazF;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,qBAAqB,GAAgE;IAChG;;;;;OAKG;IACH,CAAC,8BAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE;IAExD;;;;OAIG;IACH,CAAC,8BAAoB,CAAC,QAAQ,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,yBAAyB,CACvC,KAAiB,EACjB,EAAU,EACV,MAA+B;IAE/B,MAAM,gBAAgB,GAAG,6BAAqB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtE,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,CACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAClE,CAAC;IACF,MAAM,MAAM,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,aAAa,EAA6B,CAAC;IAEpF,IAAI,MAAM,CAAC,QAAQ,KAAK,8BAAoB,CAAC,IAAI,EAAE,CAAC;QAClD,yBAAW,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CAChC,8CAA8C,EAC9C,qBAAqB,EAAE,kGAAkG;YACvH,6DAA6D,CAChE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-alarm-config.d.ts","sourceRoot":"","sources":["../../src/topic-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAElD;;;;;;;;;OASG;IACH,iDAAiD,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAExE;;;;;;;;;;;;;;;OAeG;IACH,kCAAkC,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAEzD;;;;;;;;;;OAUG;IACH,yCAAyC,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-alarm-config.js","sourceRoot":"","sources":["../../src/topic-alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/topic-alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,2BAA2B,EAAE,mBAAmB,CAAC;IACjD,iDAAiD,EAAE,mBAAmB,CAAC;IACvE,kCAAkC,EAAE,mBAAmB,CAAC;IACxD,yCAAyC,EAAE,mBAAmB,CAAC;CAChE;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAkClC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOPIC_ALARM_DEFAULTS = void 0;
|
|
4
|
+
const aws_cloudwatch_1 = require("aws-cdk-lib/aws-cloudwatch");
|
|
5
|
+
/**
|
|
6
|
+
* AWS-recommended default alarm configuration for SNS topics.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS
|
|
9
|
+
*/
|
|
10
|
+
exports.TOPIC_ALARM_DEFAULTS = {
|
|
11
|
+
enabled: true,
|
|
12
|
+
/** Any delivery failure is worth investigating; threshold 0. */
|
|
13
|
+
numberOfNotificationsFailed: {
|
|
14
|
+
threshold: 0,
|
|
15
|
+
evaluationPeriods: 1,
|
|
16
|
+
datapointsToAlarm: 1,
|
|
17
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
18
|
+
},
|
|
19
|
+
/** Any message filtered due to invalid attributes indicates a configuration issue; threshold 0. */
|
|
20
|
+
numberOfNotificationsFilteredOutInvalidAttributes: {
|
|
21
|
+
threshold: 0,
|
|
22
|
+
evaluationPeriods: 1,
|
|
23
|
+
datapointsToAlarm: 1,
|
|
24
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
25
|
+
},
|
|
26
|
+
/** Any redrive to a subscription DLQ indicates a delivery failure worth investigating; threshold 0. */
|
|
27
|
+
numberOfNotificationsRedrivenToDlq: {
|
|
28
|
+
threshold: 0,
|
|
29
|
+
evaluationPeriods: 1,
|
|
30
|
+
datapointsToAlarm: 1,
|
|
31
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
32
|
+
},
|
|
33
|
+
/** Any failure to redrive to a DLQ means message loss; threshold 0. */
|
|
34
|
+
numberOfNotificationsFailedToRedriveToDlq: {
|
|
35
|
+
threshold: 0,
|
|
36
|
+
evaluationPeriods: 1,
|
|
37
|
+
datapointsToAlarm: 1,
|
|
38
|
+
treatMissingData: aws_cloudwatch_1.TreatMissingData.NOT_BREACHING,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=topic-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-alarm-defaults.js","sourceRoot":"","sources":["../../src/topic-alarm-defaults.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAW9D;;;;GAIG;AACU,QAAA,oBAAoB,GAAuB;IACtD,OAAO,EAAE,IAAI;IAEb,gEAAgE;IAChE,2BAA2B,EAAE;QAC3B,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;IAED,mGAAmG;IACnG,iDAAiD,EAAE;QACjD,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;IAED,uGAAuG;IACvG,kCAAkC,EAAE;QAClC,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;IAED,uEAAuE;IACvE,yCAAyC,EAAE;QACzC,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,iCAAgB,CAAC,aAAa;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-alarms.d.ts","sourceRoot":"","sources":["../../src/topic-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAoC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,eAAe,EAAE,CAsFnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,GAAG,KAAK,GAAG,SAAS,EAC5C,YAAY,GAAE,sBAAsB,CAAC,MAAM,CAAC,EAAO,GAClD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB"}
|