@composurecdk/lambda 0.7.0 → 0.8.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.
Files changed (81) hide show
  1. package/README.md +138 -6
  2. package/dist/{alarm-config.d.ts → commonjs/alarm-config.d.ts} +30 -0
  3. package/dist/commonjs/alarm-config.d.ts.map +1 -0
  4. package/dist/commonjs/alarm-config.js +3 -0
  5. package/dist/{alarm-config.js.map → commonjs/alarm-config.js.map} +1 -1
  6. package/dist/{alarm-defaults.d.ts → commonjs/alarm-defaults.d.ts} +2 -0
  7. package/dist/commonjs/alarm-defaults.d.ts.map +1 -0
  8. package/dist/commonjs/alarm-defaults.js +61 -0
  9. package/dist/commonjs/alarm-defaults.js.map +1 -0
  10. package/dist/commonjs/defaults.d.ts.map +1 -0
  11. package/dist/commonjs/defaults.js +23 -0
  12. package/dist/commonjs/defaults.js.map +1 -0
  13. package/dist/commonjs/event-sources/composure-event-source.d.ts +76 -0
  14. package/dist/commonjs/event-sources/composure-event-source.d.ts.map +1 -0
  15. package/dist/commonjs/event-sources/composure-event-source.js +36 -0
  16. package/dist/commonjs/event-sources/composure-event-source.js.map +1 -0
  17. package/dist/commonjs/event-sources/sqs-event-source.d.ts +54 -0
  18. package/dist/commonjs/event-sources/sqs-event-source.d.ts.map +1 -0
  19. package/dist/commonjs/event-sources/sqs-event-source.js +80 -0
  20. package/dist/commonjs/event-sources/sqs-event-source.js.map +1 -0
  21. package/dist/{function-alarms.d.ts → commonjs/function-alarms.d.ts} +5 -2
  22. package/dist/commonjs/function-alarms.d.ts.map +1 -0
  23. package/dist/commonjs/function-alarms.js +191 -0
  24. package/dist/commonjs/function-alarms.js.map +1 -0
  25. package/dist/commonjs/function-builder.d.ts +252 -0
  26. package/dist/commonjs/function-builder.d.ts.map +1 -0
  27. package/dist/commonjs/function-builder.js +233 -0
  28. package/dist/commonjs/function-builder.js.map +1 -0
  29. package/dist/{index.d.ts → commonjs/index.d.ts} +2 -0
  30. package/dist/commonjs/index.d.ts.map +1 -0
  31. package/dist/commonjs/index.js +13 -0
  32. package/dist/commonjs/index.js.map +1 -0
  33. package/dist/commonjs/package.json +3 -0
  34. package/dist/esm/alarm-config.d.ts +114 -0
  35. package/dist/esm/alarm-config.d.ts.map +1 -0
  36. package/dist/esm/alarm-config.js.map +1 -0
  37. package/dist/esm/alarm-defaults.d.ts +19 -0
  38. package/dist/esm/alarm-defaults.d.ts.map +1 -0
  39. package/dist/{alarm-defaults.js → esm/alarm-defaults.js} +14 -0
  40. package/dist/esm/alarm-defaults.js.map +1 -0
  41. package/dist/esm/defaults.d.ts +8 -0
  42. package/dist/esm/defaults.d.ts.map +1 -0
  43. package/dist/esm/defaults.js.map +1 -0
  44. package/dist/esm/event-sources/composure-event-source.d.ts +76 -0
  45. package/dist/esm/event-sources/composure-event-source.d.ts.map +1 -0
  46. package/dist/esm/event-sources/composure-event-source.js +31 -0
  47. package/dist/esm/event-sources/composure-event-source.js.map +1 -0
  48. package/dist/esm/event-sources/sqs-event-source.d.ts +54 -0
  49. package/dist/esm/event-sources/sqs-event-source.d.ts.map +1 -0
  50. package/dist/esm/event-sources/sqs-event-source.js +76 -0
  51. package/dist/esm/event-sources/sqs-event-source.js.map +1 -0
  52. package/dist/esm/function-alarms.d.ts +31 -0
  53. package/dist/esm/function-alarms.d.ts.map +1 -0
  54. package/dist/{function-alarms.js → esm/function-alarms.js} +69 -4
  55. package/dist/esm/function-alarms.js.map +1 -0
  56. package/dist/esm/function-builder.d.ts +252 -0
  57. package/dist/esm/function-builder.d.ts.map +1 -0
  58. package/dist/esm/function-builder.js +230 -0
  59. package/dist/esm/function-builder.js.map +1 -0
  60. package/dist/esm/index.d.ts +7 -0
  61. package/dist/esm/index.d.ts.map +1 -0
  62. package/dist/{index.js → esm/index.js} +1 -0
  63. package/dist/esm/index.js.map +1 -0
  64. package/dist/esm/package.json +3 -0
  65. package/package.json +38 -18
  66. package/dist/alarm-config.d.ts.map +0 -1
  67. package/dist/alarm-defaults.d.ts.map +0 -1
  68. package/dist/alarm-defaults.js.map +0 -1
  69. package/dist/defaults.d.ts.map +0 -1
  70. package/dist/defaults.js.map +0 -1
  71. package/dist/function-alarms.d.ts.map +0 -1
  72. package/dist/function-alarms.js.map +0 -1
  73. package/dist/function-builder.d.ts +0 -140
  74. package/dist/function-builder.d.ts.map +0 -1
  75. package/dist/function-builder.js +0 -67
  76. package/dist/function-builder.js.map +0 -1
  77. package/dist/index.d.ts.map +0 -1
  78. package/dist/index.js.map +0 -1
  79. /package/dist/{defaults.d.ts → commonjs/defaults.d.ts} +0 -0
  80. /package/dist/{alarm-config.js → esm/alarm-config.js} +0 -0
  81. /package/dist/{defaults.js → esm/defaults.js} +0 -0
@@ -0,0 +1,76 @@
1
+ import { MetricType } from "aws-cdk-lib/aws-lambda";
2
+ import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
3
+ import { isRef } from "@composurecdk/core";
4
+ import { composureEventSource } from "./composure-event-source.js";
5
+ /**
6
+ * Secure, AWS-recommended defaults applied to every SQS event source built
7
+ * with {@link sqsEventSource}. Each property can be overridden via the
8
+ * factory's `props` argument.
9
+ */
10
+ export const DEFAULT_SQS_EVENT_SOURCE_PROPS = {
11
+ /**
12
+ * Report partial batch failures so a single poison message does not fail
13
+ * the whole batch and force redelivery of already-processed records. CDK
14
+ * defaults this to `false`.
15
+ * @see https://aws.amazon.com/blogs/compute/implementing-aws-well-architected-best-practices-for-amazon-sqs-part-3/
16
+ * @see https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
17
+ */
18
+ reportBatchItemFailures: true,
19
+ /**
20
+ * Enable the per-mapping `EventCount` ESM metrics (`FailedInvokeEventCount`,
21
+ * `DroppedEventCount`, …). They emit only when opted in, and the
22
+ * event-source contextual alarms on {@link IFunctionBuilder} depend on them.
23
+ * @see https://aws.amazon.com/blogs/compute/introducing-new-event-source-mapping-esm-metrics-for-aws-lambda/
24
+ */
25
+ metricsConfig: { metrics: [MetricType.EVENT_COUNT] },
26
+ };
27
+ /**
28
+ * Wraps an SQS queue as a Lambda {@link IEventSource}, deferring resolution
29
+ * when the queue is a `ref()` to a sibling component's output.
30
+ *
31
+ * Follows the `events/targets` factory shape: register the result with
32
+ * {@link IFunctionBuilder.addEventSource} and the builder resolves the
33
+ * `ref()`, attaches the source, and (because `addEventSource` calls
34
+ * `source.bind(fn)`) grants the function's least-privilege execution role
35
+ * permission to consume the queue.
36
+ *
37
+ * Applies {@link DEFAULT_SQS_EVENT_SOURCE_PROPS}; pass `props` to override.
38
+ *
39
+ * ## Cross-component invariants (not enforced)
40
+ *
41
+ * AWS Well-Architected guidance spans the queue and the function:
42
+ * - the source queue's visibility timeout should be ≥ 6× the function
43
+ * timeout, leaving room for Lambda to retry a throttled batch;
44
+ * - the source queue's redrive `maxReceiveCount` should be ≥ 5 before the DLQ.
45
+ *
46
+ * These are not validated here — the queue often arrives as a `ref()` that is
47
+ * not resolvable at configuration time. Tracked in laazyj/composureCDK#123
48
+ * and #124.
49
+ *
50
+ * @param queue - The source queue, concrete or a `ref()` to a sibling.
51
+ * @param props - Overrides for {@link DEFAULT_SQS_EVENT_SOURCE_PROPS} and any
52
+ * other {@link SqsEventSourceProps}.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * compose(
57
+ * {
58
+ * orders: createQueueBuilder().queueName("orders"),
59
+ * processor: createFunctionBuilder()
60
+ * .runtime(Runtime.NODEJS_22_X)
61
+ * .handler("index.handler")
62
+ * .code(Code.fromAsset("lambda"))
63
+ * .addEventSource("orders", sqsEventSource(ref("orders", (r) => r.queue))),
64
+ * },
65
+ * { orders: [], processor: ["orders"] },
66
+ * );
67
+ * ```
68
+ */
69
+ export function sqsEventSource(queue, props) {
70
+ const merged = { ...DEFAULT_SQS_EVENT_SOURCE_PROPS, ...props };
71
+ const source = isRef(queue)
72
+ ? queue.map((resolved) => new SqsEventSource(resolved, merged))
73
+ : new SqsEventSource(queue, merged);
74
+ return composureEventSource("sqs", source);
75
+ }
76
+ //# sourceMappingURL=sqs-event-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqs-event-source.js","sourceRoot":"","sources":["../../../src/event-sources/sqs-event-source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAA4B,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EAAE,KAAK,EAAmB,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAA6B,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAGvC;IACF;;;;;;OAMG;IACH,uBAAuB,EAAE,IAAI;IAE7B;;;;;OAKG;IACH,aAAa,EAAE,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;CACrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAyB,EACzB,KAA2B;IAE3B,MAAM,MAAM,GAAwB,EAAE,GAAG,8BAA8B,EAAE,GAAG,KAAK,EAAE,CAAC;IACpF,MAAM,MAAM,GAA6B,KAAK,CAAC,KAAK,CAAC;QACnD,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC/D,CAAC,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
2
+ import type { Function as LambdaFunction, FunctionProps } from "aws-cdk-lib/aws-lambda";
3
+ import type { IConstruct } from "constructs";
4
+ import type { AlarmDefinition } from "@composurecdk/cloudwatch";
5
+ import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
6
+ import type { FunctionAlarmConfig } from "./alarm-config.js";
7
+ import type { AttachedEventSource } from "./event-sources/composure-event-source.js";
8
+ /**
9
+ * Resolves the recommended alarm configuration into fully-resolved
10
+ * {@link AlarmDefinition}s, applying contextual logic for timeout-based
11
+ * duration and reserved-concurrency-based concurrent execution alarms.
12
+ */
13
+ export declare function resolveFunctionAlarmDefinitions(fn: LambdaFunction, config: FunctionAlarmConfig | undefined, props: Pick<FunctionProps, "timeout" | "reservedConcurrentExecutions">, eventSources?: AttachedEventSource[]): AlarmDefinition[];
14
+ /**
15
+ * Creates AWS-recommended CloudWatch alarms for a Lambda function,
16
+ * merging recommended definitions with any custom alarm builders.
17
+ *
18
+ * @param scope - CDK construct scope for creating alarm constructs.
19
+ * @param id - Base identifier for alarm construct ids.
20
+ * @param fn - The Lambda function to create alarms for.
21
+ * @param config - User-provided alarm configuration, or `false` to disable all.
22
+ * @param props - The merged function props, used for contextual alarm thresholds.
23
+ * @param eventSources - Event sources attached to the function, used for
24
+ * per-event-source contextual alarms.
25
+ * @param customAlarms - Custom alarm builders added via `addAlarm()`.
26
+ * @returns A record mapping alarm keys to their created Alarm constructs.
27
+ *
28
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda
29
+ */
30
+ export declare function createFunctionAlarms(scope: IConstruct, id: string, fn: LambdaFunction, config: FunctionAlarmConfig | false | undefined, props: Pick<FunctionProps, "timeout" | "reservedConcurrentExecutions">, eventSources?: AttachedEventSource[], customAlarms?: AlarmDefinitionBuilder<LambdaFunction>[]): Record<string, Alarm>;
31
+ //# sourceMappingURL=function-alarms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-alarms.d.ts","sourceRoot":"","sources":["../../src/function-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EAKX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAoC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AA2CrF;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,mBAAmB,GAAG,SAAS,EACvC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,8BAA8B,CAAC,EACtE,YAAY,GAAE,mBAAmB,EAAO,GACvC,eAAe,EAAE,CAqGnB;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,mBAAmB,GAAG,KAAK,GAAG,SAAS,EAC/C,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,8BAA8B,CAAC,EACtE,YAAY,GAAE,mBAAmB,EAAO,EACxC,YAAY,GAAE,sBAAsB,CAAC,cAAc,CAAC,EAAO,GAC1D,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB"}
@@ -1,15 +1,40 @@
1
1
  import { Duration } from "aws-cdk-lib";
2
- import { ComparisonOperator, Stats, } from "aws-cdk-lib/aws-cloudwatch";
2
+ import { ComparisonOperator, Metric, Stats, } from "aws-cdk-lib/aws-cloudwatch";
3
3
  import { createAlarms, resolveAlarmConfig } from "@composurecdk/cloudwatch";
4
4
  import { FUNCTION_ALARM_DEFAULTS } from "./alarm-defaults.js";
5
5
  const METRIC_PERIOD = Duration.minutes(1);
6
6
  const METRIC_PERIOD_LABEL = `${String(METRIC_PERIOD.toMinutes())} minute`;
7
+ /**
8
+ * Contextual alarm specs keyed by source kind: each attached event source
9
+ * of a kind contributes one alarm per spec, dimensioned on its mapping UUID.
10
+ *
11
+ * @see https://aws.amazon.com/blogs/compute/introducing-new-event-source-mapping-esm-metrics-for-aws-lambda/
12
+ */
13
+ const EVENT_SOURCE_ALARM_SPECS = {
14
+ sqs: [
15
+ {
16
+ keySuffix: "FailedInvocations",
17
+ configKey: "eventSourceFailedInvocations",
18
+ metricName: "FailedInvokeEventCount",
19
+ describe: (key, threshold) => `Lambda event source "${key}" is failing to invoke the function. ` +
20
+ `Threshold: > ${String(threshold)} failed invocations in ${METRIC_PERIOD_LABEL}.`,
21
+ },
22
+ {
23
+ keySuffix: "DroppedEvents",
24
+ configKey: "eventSourceDroppedEvents",
25
+ metricName: "DroppedEventCount",
26
+ describe: (key, threshold) => `Lambda event source "${key}" is dropping events after exhausting retries or TTL. ` +
27
+ `Threshold: > ${String(threshold)} dropped events in ${METRIC_PERIOD_LABEL}.`,
28
+ },
29
+ ],
30
+ unknown: [],
31
+ };
7
32
  /**
8
33
  * Resolves the recommended alarm configuration into fully-resolved
9
34
  * {@link AlarmDefinition}s, applying contextual logic for timeout-based
10
35
  * duration and reserved-concurrency-based concurrent execution alarms.
11
36
  */
12
- export function resolveFunctionAlarmDefinitions(fn, config, props) {
37
+ export function resolveFunctionAlarmDefinitions(fn, config, props, eventSources = []) {
13
38
  if (config?.enabled === false)
14
39
  return [];
15
40
  const definitions = [];
@@ -76,8 +101,46 @@ export function resolveFunctionAlarmDefinitions(fn, config, props) {
76
101
  description: `Lambda function concurrent executions approaching reserved concurrency limit. Threshold: >= ${String(threshold)} (${String(cfg.thresholdPercent * 100)}% of ${String(reservedConcurrency)} reserved).`,
77
102
  });
78
103
  }
104
+ for (const eventSource of eventSources) {
105
+ // The ESM metrics that back these alarms are dimensioned on the mapping
106
+ // UUID; without it (e.g. a bare escape-hatch source) there is nothing to
107
+ // alarm on.
108
+ if (eventSource.eventSourceMappingId === undefined)
109
+ continue;
110
+ for (const spec of EVENT_SOURCE_ALARM_SPECS[eventSource.kind]) {
111
+ const userConfig = config?.[spec.configKey];
112
+ if (userConfig === false)
113
+ continue;
114
+ const cfg = resolveAlarmConfig(userConfig, FUNCTION_ALARM_DEFAULTS[spec.configKey]);
115
+ definitions.push({
116
+ key: `${eventSource.key}${spec.keySuffix}`,
117
+ alarmName: cfg.alarmName,
118
+ metric: eventSourceMetric(eventSource.eventSourceMappingId, spec.metricName),
119
+ threshold: cfg.threshold,
120
+ comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD,
121
+ evaluationPeriods: cfg.evaluationPeriods,
122
+ datapointsToAlarm: cfg.datapointsToAlarm,
123
+ treatMissingData: cfg.treatMissingData,
124
+ description: spec.describe(eventSource.key, cfg.threshold),
125
+ });
126
+ }
127
+ }
79
128
  return definitions;
80
129
  }
130
+ /**
131
+ * Builds an `AWS/Lambda` event source mapping metric. These per-mapping ESM
132
+ * metrics are dimensioned on `EventSourceMappingUUID` rather than
133
+ * `FunctionName`, so they cannot use the function's built-in metric helpers.
134
+ */
135
+ function eventSourceMetric(eventSourceMappingId, metricName) {
136
+ return new Metric({
137
+ namespace: "AWS/Lambda",
138
+ metricName,
139
+ dimensionsMap: { EventSourceMappingUUID: eventSourceMappingId },
140
+ statistic: Stats.SUM,
141
+ period: METRIC_PERIOD,
142
+ });
143
+ }
81
144
  /**
82
145
  * Creates AWS-recommended CloudWatch alarms for a Lambda function,
83
146
  * merging recommended definitions with any custom alarm builders.
@@ -87,18 +150,20 @@ export function resolveFunctionAlarmDefinitions(fn, config, props) {
87
150
  * @param fn - The Lambda function to create alarms for.
88
151
  * @param config - User-provided alarm configuration, or `false` to disable all.
89
152
  * @param props - The merged function props, used for contextual alarm thresholds.
153
+ * @param eventSources - Event sources attached to the function, used for
154
+ * per-event-source contextual alarms.
90
155
  * @param customAlarms - Custom alarm builders added via `addAlarm()`.
91
156
  * @returns A record mapping alarm keys to their created Alarm constructs.
92
157
  *
93
158
  * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda
94
159
  */
95
- export function createFunctionAlarms(scope, id, fn, config, props, customAlarms = []) {
160
+ export function createFunctionAlarms(scope, id, fn, config, props, eventSources = [], customAlarms = []) {
96
161
  if (config === false)
97
162
  return {};
98
163
  const enabled = config?.enabled ?? FUNCTION_ALARM_DEFAULTS.enabled;
99
164
  if (!enabled)
100
165
  return {};
101
- const recommended = resolveFunctionAlarmDefinitions(fn, config, props);
166
+ const recommended = resolveFunctionAlarmDefinitions(fn, config, props, eventSources);
102
167
  const custom = customAlarms.map((b) => b.resolve(fn));
103
168
  return createAlarms(scope, id, [...recommended, ...custom]);
104
169
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-alarms.js","sourceRoot":"","sources":["../../src/function-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAEL,kBAAkB,EAClB,MAAM,EACN,KAAK,GAEN,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAA0B,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAMpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,GAAG,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AAY1E;;;;;GAKG;AACH,MAAM,wBAAwB,GAAgE;IAC5F,GAAG,EAAE;QACH;YACE,SAAS,EAAE,mBAAmB;YAC9B,SAAS,EAAE,8BAA8B;YACzC,UAAU,EAAE,wBAAwB;YACpC,QAAQ,EAAE,CAAC,GAAG,EAAE,S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,QAAQ,CAAC,iBAAiB;QAC9E,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,IAAI,QAAQ,CAAC,gBAAgB;KAC5E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,252 @@
1
+ import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
2
+ import { type IRole } from "aws-cdk-lib/aws-iam";
3
+ import { Function as LambdaFunction, type FunctionProps, type IEventSource } from "aws-cdk-lib/aws-lambda";
4
+ import type { LogGroup } from "aws-cdk-lib/aws-logs";
5
+ import { type IConstruct } from "constructs";
6
+ import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
7
+ import { type ITaggedBuilder } from "@composurecdk/cloudformation";
8
+ import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
9
+ import { type IRoleBuilder } from "@composurecdk/iam";
10
+ import type { FunctionAlarmConfig } from "./alarm-config.js";
11
+ import { type ComposureEventSource } from "./event-sources/composure-event-source.js";
12
+ /**
13
+ * Configuration properties for the Lambda function builder.
14
+ *
15
+ * Extends the CDK {@link FunctionProps} with builder-specific options. The
16
+ * `role` prop is widened to {@link Resolvable} so a role built by a sibling
17
+ * component can be referenced via `ref(...)` at configuration time.
18
+ */
19
+ export interface FunctionBuilderProps extends Omit<FunctionProps, "role"> {
20
+ /**
21
+ * The IAM execution role to attach to the function. When set, the builder
22
+ * skips creating its own role and the auto-created `LogsWriter` inline
23
+ * policy is **not** added — the caller is fully responsible for the role's
24
+ * permissions.
25
+ *
26
+ * Accepts a concrete {@link IRole} or a {@link Resolvable} for
27
+ * cross-component wiring (e.g. `ref("sharedRole", r => r.role)`).
28
+ *
29
+ * Mutually exclusive with {@link IFunctionBuilder.configureRole} and
30
+ * {@link IFunctionBuilder.useCdkAutoRole}.
31
+ */
32
+ role?: Resolvable<IRole>;
33
+ /**
34
+ * Configuration for AWS-recommended CloudWatch alarms.
35
+ *
36
+ * By default, the builder creates recommended alarms with sensible
37
+ * thresholds for every applicable metric. Individual alarms can be
38
+ * customized or disabled. Set to `false` to disable all alarms.
39
+ *
40
+ * No alarm actions are configured by default since notification
41
+ * methods are user-specific. Access alarms from the build result
42
+ * or use an `afterBuild` hook to apply actions.
43
+ *
44
+ * Contextual alarms are only created when the corresponding function
45
+ * configuration is present: `duration` when `timeout` is set,
46
+ * `concurrentExecutions` when `reservedConcurrentExecutions` is set, and
47
+ * the event-source alarms (`eventSourceFailedInvocations`,
48
+ * `eventSourceDroppedEvents`) once an event source is attached via
49
+ * {@link IFunctionBuilder.addEventSource}.
50
+ *
51
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda
52
+ */
53
+ recommendedAlarms?: FunctionAlarmConfig | false;
54
+ }
55
+ /**
56
+ * The build output of a {@link IFunctionBuilder}. Contains the CDK constructs
57
+ * created during {@link Lifecycle.build}, keyed by role.
58
+ */
59
+ export interface FunctionBuilderResult {
60
+ /** The Lambda function construct created by the builder. */
61
+ function: LambdaFunction;
62
+ /**
63
+ * The IAM execution role attached to the function. Always populated:
64
+ * - if the caller supplied a role via {@link IFunctionBuilder.role}, this
65
+ * is that role;
66
+ * - if {@link IFunctionBuilder.useCdkAutoRole} was called, this is CDK's
67
+ * auto-created role;
68
+ * - otherwise, this is the explicit role the builder constructed via
69
+ * `@composurecdk/iam`'s `createServiceRoleBuilder`, with an inline
70
+ * `LogsWriter` policy scoped to the function's auto-created log group.
71
+ */
72
+ role: IRole;
73
+ /**
74
+ * The CloudWatch LogGroup created for the function, or `undefined` if
75
+ * the user provided their own via the `logGroup` property.
76
+ *
77
+ * By default the builder creates a managed LogGroup using
78
+ * {@link createLogGroupBuilder} with well-architected defaults (retention
79
+ * policy, removal policy). This follows AWS CDK guidance to create a
80
+ * `LogGroup` explicitly rather than relying on the auto-created default,
81
+ * which cannot be configured via CDK.
82
+ *
83
+ * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html
84
+ * @see https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs-loggroups.html
85
+ */
86
+ logGroup?: LogGroup;
87
+ /**
88
+ * CloudWatch alarms created for the function, keyed by alarm name.
89
+ *
90
+ * Includes both AWS-recommended alarms and any custom alarms added
91
+ * via {@link IFunctionBuilder.addAlarm}. Access individual alarms
92
+ * by key (e.g., `result.alarms.errors`).
93
+ *
94
+ * No alarm actions are configured — apply them via the result or an
95
+ * `afterBuild` hook.
96
+ *
97
+ * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda
98
+ */
99
+ alarms: Record<string, Alarm>;
100
+ /**
101
+ * Event sources attached to the function via
102
+ * {@link IFunctionBuilder.addEventSource}, keyed by the key passed to that
103
+ * call. Each value is the resolved CDK {@link IEventSource} — for sources
104
+ * built by a ComposureCDK factory (e.g. {@link sqsEventSource}) the
105
+ * concrete type is preserved, so callers can read back post-`bind()` state
106
+ * such as `eventSourceMappingId`.
107
+ *
108
+ * Always present — `{}` when no event sources were added.
109
+ */
110
+ eventSources: Record<string, IEventSource>;
111
+ }
112
+ /**
113
+ * A fluent builder for configuring and creating an AWS Lambda function.
114
+ *
115
+ * Each configuration property from the CDK {@link FunctionProps} is exposed
116
+ * as an overloaded method: call with a value to set it (returns the builder
117
+ * for chaining), or call with no arguments to read the current value.
118
+ *
119
+ * The builder implements {@link Lifecycle}, so it can be used directly as a
120
+ * component in a {@link compose | composed system}. When built, it creates
121
+ * a Lambda function with the configured properties and returns a
122
+ * {@link FunctionBuilderResult}.
123
+ *
124
+ * Unless a user-supplied `logGroup` is provided, the builder automatically
125
+ * creates a managed CloudWatch LogGroup via {@link createLogGroupBuilder}
126
+ * with well-architected defaults (retention, removal policy) and wires it
127
+ * to the function. This ensures full control over log lifecycle and follows
128
+ * AWS CDK guidance to create a LogGroup explicitly.
129
+ *
130
+ * ## Execution role
131
+ *
132
+ * By default the builder creates an explicit IAM role via
133
+ * `@composurecdk/iam`'s `createServiceRoleBuilder("lambda.amazonaws.com")`,
134
+ * with an inline `LogsWriter` policy granting `logs:CreateLogStream` and
135
+ * `logs:PutLogEvents` scoped to the function's auto-created log group.
136
+ * This replaces CDK's default auto-role (which attaches the
137
+ * `AWSLambdaBasicExecutionRole` managed policy granting wildcard log
138
+ * access) with a least-privilege role.
139
+ *
140
+ * Three override seams are available, in order of preference:
141
+ *
142
+ * 1. {@link IFunctionBuilder.configureRole} — extend the default role
143
+ * builder with additional inline policies, etc.
144
+ * 2. {@link IFunctionBuilder.role} — supply a fully external role; no
145
+ * `LogsWriter` policy is added.
146
+ * 3. {@link IFunctionBuilder.useCdkAutoRole} — opt back into CDK's
147
+ * auto-created role with `AWSLambdaBasicExecutionRole`.
148
+ *
149
+ * The seams are mutually exclusive; combining any two throws at build time.
150
+ *
151
+ * The builder also creates AWS-recommended CloudWatch alarms by default.
152
+ * Alarms can be customized or disabled via the `recommendedAlarms` property.
153
+ * Custom alarms can be added via the {@link addAlarm} method.
154
+ *
155
+ * @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * const handler = createFunctionBuilder()
160
+ * .runtime(Runtime.NODEJS_22_X)
161
+ * .handler("index.handler")
162
+ * .code(Code.fromAsset("lambda"))
163
+ * .memorySize(256)
164
+ * .timeout(Duration.seconds(30));
165
+ * ```
166
+ */
167
+ export type IFunctionBuilder = ITaggedBuilder<FunctionBuilderProps, FunctionBuilder>;
168
+ declare class FunctionBuilder implements Lifecycle<FunctionBuilderResult> {
169
+ #private;
170
+ props: Partial<FunctionBuilderProps>;
171
+ addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<LambdaFunction>) => AlarmDefinitionBuilder<LambdaFunction>): this;
172
+ /**
173
+ * Register an event source to be attached to the function at build time.
174
+ *
175
+ * A Lambda function can have many event sources of mixed types, so this
176
+ * hook is repeatable and typed to the common {@link IEventSource}. Pass a
177
+ * {@link ComposureEventSource} from a ComposureCDK factory (e.g. {@link sqsEventSource})
178
+ * or a bare concrete {@link IEventSource}.
179
+ *
180
+ * At build time the source is resolved and attached *after* the function
181
+ * (and its least-privilege execution role) exist, so the `source.bind(fn)`
182
+ * that `addEventSource` performs grants the consume permission onto the
183
+ * builder's role. The resolved source is exposed on
184
+ * {@link FunctionBuilderResult.eventSources} under `key`.
185
+ *
186
+ * Sources built by a recognised factory also enable contextual alarms —
187
+ * see {@link FunctionBuilderProps.recommendedAlarms}.
188
+ *
189
+ * @throws If `key` was already used by a previous `addEventSource` call.
190
+ */
191
+ addEventSource(key: string, source: Resolvable<ComposureEventSource | IEventSource>): this;
192
+ /**
193
+ * Extend the default execution-role builder with additional configuration
194
+ * (inline policies, managed-policy attachments, description, etc.).
195
+ *
196
+ * The callback receives the internal {@link IRoleBuilder} that the function
197
+ * builder will use to construct the role. Calling `configureRole` more than
198
+ * once replaces the previous callback. The default `LogsWriter` inline
199
+ * policy is added before the callback runs; supplying another inline
200
+ * policy with the name `LogsWriter` throws at build time.
201
+ *
202
+ * Mutually exclusive with {@link role} and {@link useCdkAutoRole}.
203
+ */
204
+ configureRole(fn: (rb: IRoleBuilder) => unknown): this;
205
+ /**
206
+ * Opt back into CDK's auto-created execution role attached to the
207
+ * `AWSLambdaBasicExecutionRole` managed policy.
208
+ *
209
+ * **Not the recommended path.** The default builder-created role grants
210
+ * `logs:CreateLogStream` and `logs:PutLogEvents` scoped to the function's
211
+ * own log group; CDK's auto-role grants those actions on `*` and also
212
+ * permits `logs:CreateLogGroup` arbitrarily. Use this escape hatch only
213
+ * when matching an existing stack's logical IDs during a phased migration
214
+ * or when the wildcard log surface is a deliberate trade-off.
215
+ *
216
+ * Mutually exclusive with {@link role} and {@link configureRole}.
217
+ */
218
+ useCdkAutoRole(): this;
219
+ /** @internal — see ADR-0005. */
220
+ [COPY_STATE](target: FunctionBuilder): void;
221
+ build(scope: IConstruct, id: string, context?: Record<string, object>): FunctionBuilderResult;
222
+ }
223
+ /**
224
+ * Creates a new {@link IFunctionBuilder} for configuring an AWS Lambda function.
225
+ *
226
+ * This is the entry point for defining a Lambda function component. The returned
227
+ * builder exposes every {@link FunctionBuilderProps} property as a fluent setter/getter
228
+ * and implements {@link Lifecycle} for use with {@link compose}.
229
+ *
230
+ * @returns A fluent builder for an AWS Lambda function.
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * const handler = createFunctionBuilder()
235
+ * .runtime(Runtime.NODEJS_22_X)
236
+ * .handler("index.handler")
237
+ * .code(Code.fromAsset("lambda"))
238
+ * .timeout(Duration.seconds(30));
239
+ *
240
+ * // Use standalone:
241
+ * const result = handler.build(stack, "MyFunction");
242
+ *
243
+ * // Or compose into a system:
244
+ * const system = compose(
245
+ * { handler, table: createTableBuilder() },
246
+ * { handler: ["table"], table: [] },
247
+ * );
248
+ * ```
249
+ */
250
+ export declare function createFunctionBuilder(): IFunctionBuilder;
251
+ export {};
252
+ //# sourceMappingURL=function-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-builder.d.ts","sourceRoot":"","sources":["../../src/function-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,KAAK,EAAiB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OA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