@composurecdk/lambda 0.10.0 → 0.10.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.
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVOKE_ON_DEPLOY_DEFAULTS = exports.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID = void 0;
4
+ exports.createDeploymentTrigger = createDeploymentTrigger;
5
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
6
+ const triggers_1 = require("aws-cdk-lib/triggers");
7
+ const core_1 = require("@composurecdk/core");
8
+ /**
9
+ * Suppression id for the deploy-time invocation timeout guard. Stable and part
10
+ * of the public surface — silence the warning with
11
+ * `Annotations.of(scope).acknowledgeWarning(INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID)`,
12
+ * so it must not be renamed casually.
13
+ */
14
+ exports.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID = "@composurecdk/lambda:invoke-on-deploy-timeout";
15
+ /**
16
+ * The deployment waits for the handler's response, so a handler that throws
17
+ * fails the stack. An invariant of the action rather than a default: the
18
+ * asynchronous alternative returns before the work happens, reporting success
19
+ * whatever the handler did, so there is nothing to override to.
20
+ *
21
+ * @see https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/rel_tracking_change_management_deployment_management.html
22
+ */
23
+ const INVOCATION_TYPE = triggers_1.InvocationType.REQUEST_RESPONSE;
24
+ /**
25
+ * The trigger provider's own Lambda timeout. CDK builds that provider from
26
+ * `CustomResourceProviderBase`, which defaults to 15 minutes, and `Trigger`
27
+ * overrides nothing — so there is no seam to raise it through and no way to
28
+ * read it back. Asserted against a synthesised template in the test suite, so
29
+ * an `aws-cdk-lib` upgrade that changes the default fails loudly here rather
30
+ * than quietly reopening the hang this ceiling exists to prevent.
31
+ */
32
+ const PROVIDER_TIMEOUT = aws_cdk_lib_1.Duration.minutes(15);
33
+ /**
34
+ * Added to the function's own `timeout` to derive the wait, and subtracted
35
+ * from {@link PROVIDER_TIMEOUT} to derive {@link MAX_TIMEOUT} — the same slack
36
+ * at both ends, for the same reason: whoever is waiting must outlive whoever
37
+ * they are waiting for, or the error is never reported.
38
+ */
39
+ const TIMEOUT_MARGIN = aws_cdk_lib_1.Duration.seconds(30);
40
+ /**
41
+ * Ceiling for the wait. The provider must outlive the invocation it is waiting
42
+ * on, or it dies mid-wait and posts nothing back to CloudFormation. `Trigger`
43
+ * sets no `ServiceTimeout` on the custom resource, so that is not a failed
44
+ * deployment — it is a *hung* one, until CloudFormation abandons the stack
45
+ * operation of its own accord.
46
+ */
47
+ const MAX_TIMEOUT = PROVIDER_TIMEOUT.minus(TIMEOUT_MARGIN);
48
+ /**
49
+ * The wait applied when the function's own timeout is unset or a token, and so
50
+ * yields no concrete value to derive from. Matches the CDK `Trigger` default.
51
+ */
52
+ const FALLBACK_TIMEOUT = aws_cdk_lib_1.Duration.minutes(2);
53
+ /**
54
+ * How {@link IFunctionBuilder.invokeOnDeploy | `.invokeOnDeploy()`} derives the
55
+ * wait when the caller sets no {@link InvokeOnDeployOptions.timeout}. A public
56
+ * mirror of this module's constants, exported for visibility and testing — the
57
+ * rationale for each value is on the constant it mirrors.
58
+ */
59
+ exports.INVOKE_ON_DEPLOY_DEFAULTS = {
60
+ /** @see {@link TIMEOUT_MARGIN} */
61
+ timeoutMargin: TIMEOUT_MARGIN,
62
+ /** @see {@link FALLBACK_TIMEOUT} */
63
+ fallbackTimeout: FALLBACK_TIMEOUT,
64
+ /** @see {@link MAX_TIMEOUT} */
65
+ maxTimeout: MAX_TIMEOUT,
66
+ };
67
+ /**
68
+ * Creates the custom resource that invokes `handler` during deployment and
69
+ * fails the stack if it errors.
70
+ *
71
+ * The invocation is ordered after the function's execution role, so the policies
72
+ * attached *to it* by `.grant()` / `.configureRole()` — which CloudFormation
73
+ * does not otherwise sequence ahead of a custom resource — exist by the time the
74
+ * handler runs.
75
+ *
76
+ * That reaches the identity half of a grant only: one that also writes a
77
+ * resource policy (a KMS key policy, a cross-account bucket policy) leaves that
78
+ * half in the granting resource's tree, and an imported role contributes no
79
+ * resources to sequence at all. Both are the consumer's to declare through
80
+ * {@link InvokeOnDeployOptions.after}, as is anything else the call needs.
81
+ *
82
+ * @internal
83
+ */
84
+ function createDeploymentTrigger(scope, id, handler, executionRole, options, context) {
85
+ const timeout = resolveWait(options.timeout, handler.timeout, id);
86
+ warnOnShortWait(handler, id, timeout);
87
+ const trigger = new triggers_1.Trigger(scope, `${id}DeploymentTrigger`, {
88
+ handler,
89
+ invocationType: INVOCATION_TYPE,
90
+ timeout,
91
+ executeOnHandlerChange: options.executeOnHandlerChange,
92
+ });
93
+ (0, core_1.addDependencies)(trigger, [executionRole, ...(options.after ?? [])], context);
94
+ return trigger;
95
+ }
96
+ /**
97
+ * How long the deployment waits.
98
+ *
99
+ * {@link MAX_TIMEOUT} binds both branches, but differently. A derived wait is
100
+ * capped: the derivation is the library's, so quietly settling for less than it
101
+ * wanted is the library's business. An explicit wait over the ceiling throws —
102
+ * clamping would honour neither the duration the caller asked for nor the
103
+ * failing deployment they expected, and there is no working form to fall back
104
+ * to. Both are silent on a token, which has no value to compare.
105
+ */
106
+ function resolveWait(explicitWait, handlerTimeout, id) {
107
+ if (explicitWait !== undefined) {
108
+ const waitSeconds = concreteSeconds(explicitWait);
109
+ if (waitSeconds !== undefined && waitSeconds > MAX_TIMEOUT.toSeconds()) {
110
+ throw new Error(`FunctionBuilder "${id}": .invokeOnDeploy() was given a timeout of ${String(waitSeconds)}s, ` +
111
+ `but the deployment cannot wait longer than ${String(MAX_TIMEOUT.toSeconds())}s — CDK's ` +
112
+ `trigger provider runs with a ${String(PROVIDER_TIMEOUT.toSeconds())}s Lambda timeout ` +
113
+ `and needs the remainder to report the result. A longer wait does not fail the ` +
114
+ `deployment, it hangs it: the provider dies mid-invocation and CloudFormation is never ` +
115
+ `told. Lower the timeout, or move work that needs longer out of the deployment.`);
116
+ }
117
+ return explicitWait;
118
+ }
119
+ const handlerSeconds = concreteSeconds(handlerTimeout);
120
+ if (handlerSeconds === undefined)
121
+ return FALLBACK_TIMEOUT;
122
+ const derived = handlerSeconds + TIMEOUT_MARGIN.toSeconds();
123
+ return aws_cdk_lib_1.Duration.seconds(Math.min(derived, MAX_TIMEOUT.toSeconds()));
124
+ }
125
+ /** A `Duration` in seconds, or `undefined` when it is unset or a token. */
126
+ function concreteSeconds(duration) {
127
+ if (duration === undefined || duration.isUnresolved())
128
+ return undefined;
129
+ return duration.toSeconds();
130
+ }
131
+ /**
132
+ * Warns when the deployment would stop waiting before the handler's own timeout
133
+ * — a handler that runs long then fails the stack as an abandoned invocation
134
+ * rather than reporting the error it was about to produce.
135
+ *
136
+ * Checked against the final wait, whether the caller set it or it was derived,
137
+ * because the derived path can land here too: the cap leaves no margin once the
138
+ * function's own timeout reaches {@link MAX_TIMEOUT}.
139
+ * Silent whenever either value is a token, with nothing to compare.
140
+ */
141
+ function warnOnShortWait(handler, id, wait) {
142
+ const waitSeconds = concreteSeconds(wait);
143
+ const handlerSeconds = concreteSeconds(handler.timeout);
144
+ if (waitSeconds === undefined || handlerSeconds === undefined)
145
+ return;
146
+ if (waitSeconds > handlerSeconds)
147
+ return;
148
+ aws_cdk_lib_1.Annotations.of(handler).addWarningV2(exports.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID, `FunctionBuilder "${id}": .invokeOnDeploy() waits ${String(waitSeconds)}s but the function's ` +
149
+ `own timeout is ${String(handlerSeconds)}s — the deployment stops waiting while the handler ` +
150
+ `is still running, so a slow call fails the stack as an abandoned invocation instead of ` +
151
+ `reporting the handler's error. Give the deployment longer than the function's timeout (up ` +
152
+ `to ${String(MAX_TIMEOUT.toSeconds())}s), shorten the function's ` +
153
+ `timeout, or acknowledge "${exports.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID}".`);
154
+ }
155
+ //# sourceMappingURL=invoke-on-deploy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invo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AAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,eAAe,CAAC,OAAuB,EAAE,EAAU,EAAE,IAAc;IAC1E,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,WAAW,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO;IACtE,IAAI,WAAW,GAAG,cAAc;QAAE,OAAO;IAEzC,yBAAW,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,YAAY,CAClC,2CAAmC,EACnC,oBAAoB,EAAE,8BAA8B,MAAM,CAAC,WAAW,CAAC,uBAAuB;QAC5F,kBAAkB,MAAM,CAAC,cAAc,CAAC,qDAAqD;QAC7F,yFAAyF;QACzF,4FAA4F;QAC5F,MAAM,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,6BAA6B;QAClE,4BAA4B,2CAAmC,IAAI,CACtE,CAAC;AACJ,CAAC"}
@@ -2,6 +2,7 @@ import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
2
2
  import { type IGrantable, type IRole } from "aws-cdk-lib/aws-iam";
3
3
  import { Function as LambdaFunction, type FunctionProps, type IEventSource } from "aws-cdk-lib/aws-lambda";
4
4
  import type { LogGroup } from "aws-cdk-lib/aws-logs";
5
+ import type { Trigger } from "aws-cdk-lib/triggers";
5
6
  import { type IConstruct } from "constructs";
6
7
  import { COPY_STATE, type Grant, type Lifecycle, type Resolvable } from "@composurecdk/core";
7
8
  import { type ITaggedBuilder } from "@composurecdk/cloudformation";
@@ -9,16 +10,18 @@ import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
9
10
  import { type IRoleBuilder } from "@composurecdk/iam";
10
11
  import type { FunctionAlarmConfig } from "./alarm-config.js";
11
12
  import { type ComposureEventSource } from "./event-sources/composure-event-source.js";
13
+ import { type InvokeOnDeployOptions } from "./invoke-on-deploy.js";
12
14
  /**
13
15
  * Configuration properties for the Lambda function builder.
14
16
  *
15
17
  * Extends the CDK {@link FunctionProps} with builder-specific options. The
16
- * `role` and `environmentEncryption` props are widened to {@link Resolvable}
17
- * so a role or key built by a sibling component can be referenced via
18
- * `ref(...)` at configuration time; both read their inner type from CDK's own
19
- * prop so they keep tracking it (ADR-0018).
18
+ * `role` and `environmentEncryption` are widened to {@link Resolvable}, and
19
+ * `environment` to a record of `Resolvable` values, so a role, key or value
20
+ * built by a sibling component can be referenced via `ref(...)` at
21
+ * configuration time. Each reads its inner type from CDK's own prop so they
22
+ * keep tracking it (ADR-0018).
20
23
  */
21
- export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "environmentEncryption"> {
24
+ export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "environmentEncryption" | "environment"> {
22
25
  /**
23
26
  * The IAM execution role to attach to the function. When set, the builder
24
27
  * skips creating its own role and the auto-created `LogsWriter` inline
@@ -52,6 +55,20 @@ export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "envi
52
55
  * @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption
53
56
  */
54
57
  environmentEncryption?: Resolvable<NonNullable<FunctionProps["environmentEncryption"]>>;
58
+ /**
59
+ * Key-value pairs the function can read from `process.env` (e.g.
60
+ * `.environment({ API_URL: ref("api", (r) => r.api.url), LOG_LEVEL: "info" })`).
61
+ *
62
+ * Each **value** is independently {@link Resolvable}, rather than the record
63
+ * as a whole, because mixing a reference with literals is the common case:
64
+ * wrapping the record would push every literal through the same `ref`, and
65
+ * through {@link combine} as soon as two siblings are involved. Matches
66
+ * `validationZones` in `@composurecdk/acm`.
67
+ *
68
+ * The value type is read from CDK's own prop rather than written as `string`,
69
+ * so it tracks `aws-cdk-lib` (ADR-0018).
70
+ */
71
+ environment?: Record<string, Resolvable<NonNullable<FunctionProps["environment"]>[string]>>;
55
72
  /**
56
73
  * Configuration for AWS-recommended CloudWatch alarms.
57
74
  *
@@ -131,6 +148,18 @@ export interface FunctionBuilderResult {
131
148
  * Always present — `{}` when no event sources were added.
132
149
  */
133
150
  eventSources: Record<string, IEventSource>;
151
+ /**
152
+ * The custom resource that invokes the function during deployment, or
153
+ * `undefined` unless {@link IFunctionBuilder.invokeOnDeploy} was called.
154
+ *
155
+ * Exposed so a sibling can be ordered against the invocation — e.g.
156
+ * `deploymentTrigger.executeBefore(...)` to gate another resource on the
157
+ * call having succeeded.
158
+ *
159
+ * Optional, unlike the always-present `alarms` / `eventSources` beside it:
160
+ * there is no empty `Trigger` to stand in for the absence of one.
161
+ */
162
+ deploymentTrigger?: Trigger;
134
163
  }
135
164
  /**
136
165
  * A fluent builder for configuring and creating an AWS Lambda function.
@@ -239,6 +268,48 @@ declare class FunctionBuilder implements Lifecycle<FunctionBuilderResult> {
239
268
  * Mutually exclusive with {@link role} and {@link configureRole}.
240
269
  */
241
270
  useCdkAutoRole(): this;
271
+ /**
272
+ * Invoke this function once during deployment, and **fail the deployment if
273
+ * it fails** — a domain action for work that must happen as part of shipping
274
+ * the stack, such as registering the release with an external service,
275
+ * verifying the deployed system answers correctly, or seeding reference data
276
+ * through a service API (ADR-0016).
277
+ *
278
+ * The deployment waits for the handler's response. If the handler throws or
279
+ * times out, the stack fails and rolls back, and the handler's error message
280
+ * reaches the CloudFormation stack events.
281
+ *
282
+ * **The handler must throw to fail the deployment.** Returning an error
283
+ * object — an HTTP-shaped `{ statusCode: 500 }`, or a caught error swallowed
284
+ * into the response — is a *successful* invocation as far as Lambda is
285
+ * concerned, and the deployment goes green.
286
+ *
287
+ * Ordering is data: the function's own execution role is always waited for,
288
+ * and anything else the call needs is declared with
289
+ * {@link InvokeOnDeployOptions.after}.
290
+ *
291
+ * The deployment waits for this function's own `timeout` plus 30s, rather
292
+ * than the flat 2 minutes CDK's `Trigger` defaults to, so a handler that runs
293
+ * to its limit reports *its* error instead of the deployment abandoning the
294
+ * call first. The wait is capped at 14m30s — see
295
+ * {@link InvokeOnDeployOptions.timeout}, which throws above that rather than
296
+ * clamping.
297
+ *
298
+ * Calling this more than once replaces the previous options. The resulting
299
+ * custom resource is exposed on
300
+ * {@link FunctionBuilderResult.deploymentTrigger}.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * createFunctionBuilder()
305
+ * .runtime(Runtime.NODEJS_22_X)
306
+ * .handler("index.handler")
307
+ * .code(Code.fromAsset("register"))
308
+ * .timeout(Duration.seconds(30))
309
+ * .invokeOnDeploy({ after: [ref("api", (r: RestApiBuilderResult) => r.api)] });
310
+ * ```
311
+ */
312
+ invokeOnDeploy(options?: InvokeOnDeployOptions): this;
242
313
  /**
243
314
  * Grant this function's execution role access to a resource built by a
244
315
  * sibling component.
@@ -1 +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,UAAU,EAAE,KAAK,KAAK,EAAiB,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,QAAQ,IAAI,cAAc,EAC1B,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,UAAU,EACV,KAAK,KAAK,EAEV,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7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AG,IAAI;IAS3C,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,qBAAqB;CA4IzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,CAExD"}
@@ -1,6 +1,6 @@
1
1
  import { ManagedPolicy } from "aws-cdk-lib/aws-iam";
2
2
  import { Function as LambdaFunction, } from "aws-cdk-lib/aws-lambda";
3
- import { COPY_STATE, GrantQueue, resolve, } from "@composurecdk/core";
3
+ import { combine, COPY_STATE, GrantQueue, resolve, } from "@composurecdk/core";
4
4
  import { taggedBuilder } from "@composurecdk/cloudformation";
5
5
  import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
6
6
  import { createServiceRoleBuilder, createStatementBuilder, } from "@composurecdk/iam";
@@ -9,6 +9,7 @@ import { createFunctionAlarms } from "./function-alarms.js";
9
9
  import { FUNCTION_DEFAULTS } from "./defaults.js";
10
10
  import { EVENT_SOURCE_MAPPING_ID_READERS, isComposureEventSource, } from "./event-sources/composure-event-source.js";
11
11
  import { EVENT_SOURCE_RELATIONSHIP_GUARDS } from "./event-sources/event-source-relationship-guards.js";
12
+ import { createDeploymentTrigger } from "./invoke-on-deploy.js";
12
13
  const LOGS_WRITER_POLICY_NAME = "LogsWriter";
13
14
  /**
14
15
  * The log group's ARN, wherever the installed `aws-cdk-lib` keeps it.
@@ -42,6 +43,7 @@ class FunctionBuilder {
42
43
  #grants = new GrantQueue();
43
44
  #configureRole;
44
45
  #useCdkAutoRole = false;
46
+ #invokeOnDeploy;
45
47
  addAlarm(key, configure) {
46
48
  this.#customAlarms.push(configure(new AlarmDefinitionBuilder(key)));
47
49
  return this;
@@ -105,6 +107,51 @@ class FunctionBuilder {
105
107
  this.#useCdkAutoRole = true;
106
108
  return this;
107
109
  }
110
+ /**
111
+ * Invoke this function once during deployment, and **fail the deployment if
112
+ * it fails** — a domain action for work that must happen as part of shipping
113
+ * the stack, such as registering the release with an external service,
114
+ * verifying the deployed system answers correctly, or seeding reference data
115
+ * through a service API (ADR-0016).
116
+ *
117
+ * The deployment waits for the handler's response. If the handler throws or
118
+ * times out, the stack fails and rolls back, and the handler's error message
119
+ * reaches the CloudFormation stack events.
120
+ *
121
+ * **The handler must throw to fail the deployment.** Returning an error
122
+ * object — an HTTP-shaped `{ statusCode: 500 }`, or a caught error swallowed
123
+ * into the response — is a *successful* invocation as far as Lambda is
124
+ * concerned, and the deployment goes green.
125
+ *
126
+ * Ordering is data: the function's own execution role is always waited for,
127
+ * and anything else the call needs is declared with
128
+ * {@link InvokeOnDeployOptions.after}.
129
+ *
130
+ * The deployment waits for this function's own `timeout` plus 30s, rather
131
+ * than the flat 2 minutes CDK's `Trigger` defaults to, so a handler that runs
132
+ * to its limit reports *its* error instead of the deployment abandoning the
133
+ * call first. The wait is capped at 14m30s — see
134
+ * {@link InvokeOnDeployOptions.timeout}, which throws above that rather than
135
+ * clamping.
136
+ *
137
+ * Calling this more than once replaces the previous options. The resulting
138
+ * custom resource is exposed on
139
+ * {@link FunctionBuilderResult.deploymentTrigger}.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * createFunctionBuilder()
144
+ * .runtime(Runtime.NODEJS_22_X)
145
+ * .handler("index.handler")
146
+ * .code(Code.fromAsset("register"))
147
+ * .timeout(Duration.seconds(30))
148
+ * .invokeOnDeploy({ after: [ref("api", (r: RestApiBuilderResult) => r.api)] });
149
+ * ```
150
+ */
151
+ invokeOnDeploy(options = {}) {
152
+ this.#invokeOnDeploy = options;
153
+ return this;
154
+ }
108
155
  /**
109
156
  * Grant this function's execution role access to a resource built by a
110
157
  * sibling component.
@@ -135,9 +182,10 @@ class FunctionBuilder {
135
182
  this.#grants.copyInto(target.#grants);
136
183
  target.#configureRole = this.#configureRole;
137
184
  target.#useCdkAutoRole = this.#useCdkAutoRole;
185
+ target.#invokeOnDeploy = this.#invokeOnDeploy;
138
186
  }
139
187
  build(scope, id, context = {}) {
140
- const { role: roleResolvable, environmentEncryption, recommendedAlarms: alarmConfig, ...functionProps } = this.props;
188
+ const { role: roleResolvable, environmentEncryption, environment, recommendedAlarms: alarmConfig, ...functionProps } = this.props;
141
189
  const seamCount = (roleResolvable !== undefined ? 1 : 0) +
142
190
  (this.#configureRole !== undefined ? 1 : 0) +
143
191
  (this.#useCdkAutoRole ? 1 : 0);
@@ -165,6 +213,7 @@ class FunctionBuilder {
165
213
  ...(environmentEncryption !== undefined
166
214
  ? { environmentEncryption: resolve(environmentEncryption, context) }
167
215
  : {}),
216
+ ...(environment !== undefined ? { environment: resolve(combine(environment), context) } : {}),
168
217
  };
169
218
  const fn = new LambdaFunction(scope, id, mergedProps);
170
219
  this.#grants.applyTo(fn, context);
@@ -204,7 +253,12 @@ class FunctionBuilder {
204
253
  if (!resolvedRole) {
205
254
  throw new Error(`FunctionBuilder "${id}": Lambda function has no execution role.`);
206
255
  }
207
- return { function: fn, role: resolvedRole, logGroup, alarms, eventSources };
256
+ // Built last so the invocation is ordered after everything the builder
257
+ // attached to the function — grants included.
258
+ const deploymentTrigger = this.#invokeOnDeploy
259
+ ? createDeploymentTrigger(scope, id, fn, resolvedRole, this.#invokeOnDeploy, context)
260
+ : undefined;
261
+ return { function: fn, role: resolvedRole, logGroup, alarms, eventSources, deploymentTrigger };
208
262
  }
209
263
  #buildDefaultRole(scope, id, context, logGroup) {
210
264
  if (!logGroup) {
@@ -1 +1 @@
1
- {"version":3,"file":"function-builder.js","sourceRoot":"","sources":["../../src/function-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,QAAQ,IAAI,cAAc,GAG3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,UAAU,EAEV,UAAU,EAEV,OAAO,GAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuB,aAAa,EAAE,MAAM,8BAA8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AO,OAAO,CAAC;YACjB,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAY,CAAC;QACxD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export { createFunctionBuilder, type FunctionBuilderProps, type FunctionBuilderResult, type IFunctionBuilder, } from "./function-builder.js";
2
2
  export { functionGrants } from "./grants.js";
3
3
  export { FUNCTION_DEFAULTS } from "./defaults.js";
4
+ export { INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID, INVOKE_ON_DEPLOY_DEFAULTS, type InvokeOnDeployOptions, } from "./invoke-on-deploy.js";
4
5
  export { type FunctionAlarmConfig, type PercentageAlarmConfig } from "./alarm-config.js";
5
6
  export { FUNCTION_ALARM_DEFAULTS } from "./alarm-defaults.js";
6
7
  export { type ComposureEventSource, type EventSourceKind, } from "./event-sources/composure-event-source.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,cAAc,EACd,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,iCAAiC,EACjC,KAAK,4BAA4B,GAClC,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,mCAAmC,EACnC,yBAAyB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,cAAc,EACd,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,iCAAiC,EACjC,KAAK,4BAA4B,GAClC,MAAM,0CAA0C,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { createFunctionBuilder, } from "./function-builder.js";
2
2
  export { functionGrants } from "./grants.js";
3
3
  export { FUNCTION_DEFAULTS } from "./defaults.js";
4
+ export { INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID, INVOKE_ON_DEPLOY_DEFAULTS, } from "./invoke-on-deploy.js";
4
5
  export { FUNCTION_ALARM_DEFAULTS } from "./alarm-defaults.js";
5
6
  export { sqsEventSource, DEFAULT_SQS_EVENT_SOURCE_PROPS, } from "./event-sources/sqs-event-source.js";
6
7
  export { SQS_VISIBILITY_TIMEOUT_WARNING_ID, STREAM_DLQ_WARNING_ID, } from "./event-sources/event-source-relationship-guards.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,OAAO,EACL,cAAc,EACd,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,iCAAiC,GAElC,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAItB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,mCAAmC,EACnC,yBAAyB,GAE1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,OAAO,EACL,cAAc,EACd,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,iCAAiC,GAElC,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { Duration } from "aws-cdk-lib";
2
+ import type { Function as LambdaFunction } from "aws-cdk-lib/aws-lambda";
3
+ import { Trigger } from "aws-cdk-lib/triggers";
4
+ import type { IConstruct } from "constructs";
5
+ import { type DependencySource } from "@composurecdk/core";
6
+ /**
7
+ * Suppression id for the deploy-time invocation timeout guard. Stable and part
8
+ * of the public surface — silence the warning with
9
+ * `Annotations.of(scope).acknowledgeWarning(INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID)`,
10
+ * so it must not be renamed casually.
11
+ */
12
+ export declare const INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID = "@composurecdk/lambda:invoke-on-deploy-timeout";
13
+ /**
14
+ * How {@link IFunctionBuilder.invokeOnDeploy | `.invokeOnDeploy()`} derives the
15
+ * wait when the caller sets no {@link InvokeOnDeployOptions.timeout}. A public
16
+ * mirror of this module's constants, exported for visibility and testing — the
17
+ * rationale for each value is on the constant it mirrors.
18
+ */
19
+ export declare const INVOKE_ON_DEPLOY_DEFAULTS: {
20
+ /** @see {@link TIMEOUT_MARGIN} */
21
+ readonly timeoutMargin: Duration;
22
+ /** @see {@link FALLBACK_TIMEOUT} */
23
+ readonly fallbackTimeout: Duration;
24
+ /** @see {@link MAX_TIMEOUT} */
25
+ readonly maxTimeout: Duration;
26
+ };
27
+ /**
28
+ * Options for {@link IFunctionBuilder.invokeOnDeploy | `.invokeOnDeploy()`}.
29
+ */
30
+ export interface InvokeOnDeployOptions {
31
+ /**
32
+ * What must be fully provisioned before the handler runs — see
33
+ * {@link DependencySource} for the shapes it takes and what each one reaches.
34
+ *
35
+ * The function's own execution role, and therefore every policy attached to
36
+ * it by `.grant()` or `.configureRole()`, is already waited for. This is for
37
+ * everything else the call depends on: the API it will call, the table it
38
+ * will seed — and the resource behind any grant that writes a *resource*
39
+ * policy rather than an identity one, such as a KMS key, since that half is
40
+ * not attached to the role and so is not covered.
41
+ */
42
+ readonly after?: DependencySource[];
43
+ /**
44
+ * How long the deployment waits for the handler before failing the stack.
45
+ *
46
+ * Defaults to the function's own `timeout` plus
47
+ * {@link INVOKE_ON_DEPLOY_DEFAULTS.timeoutMargin}, capped at
48
+ * {@link INVOKE_ON_DEPLOY_DEFAULTS.maxTimeout}. Setting it at or below the
49
+ * function's timeout warns under {@link INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID};
50
+ * setting it above `maxTimeout` throws, because the provider would not
51
+ * survive the wait to report anything.
52
+ */
53
+ readonly timeout?: Duration;
54
+ /**
55
+ * Re-invoke the handler whenever its code or configuration changes.
56
+ *
57
+ * `true` (the default) binds the invocation to the function's current
58
+ * version, so it re-runs on a handler change and is a no-op on unrelated
59
+ * stack updates — right for an idempotent registration. `false` invokes only
60
+ * on the stack's *first* deployment. Neither setting invokes on every
61
+ * deployment; that is not something CDK's `Trigger` offers.
62
+ */
63
+ readonly executeOnHandlerChange?: boolean;
64
+ }
65
+ /**
66
+ * Creates the custom resource that invokes `handler` during deployment and
67
+ * fails the stack if it errors.
68
+ *
69
+ * The invocation is ordered after the function's execution role, so the policies
70
+ * attached *to it* by `.grant()` / `.configureRole()` — which CloudFormation
71
+ * does not otherwise sequence ahead of a custom resource — exist by the time the
72
+ * handler runs.
73
+ *
74
+ * That reaches the identity half of a grant only: one that also writes a
75
+ * resource policy (a KMS key policy, a cross-account bucket policy) leaves that
76
+ * half in the granting resource's tree, and an imported role contributes no
77
+ * resources to sequence at all. Both are the consumer's to declare through
78
+ * {@link InvokeOnDeployOptions.after}, as is anything else the call needs.
79
+ *
80
+ * @internal
81
+ */
82
+ export declare function createDeploymentTrigger(scope: IConstruct, id: string, handler: LambdaFunction, executionRole: IConstruct, options: InvokeOnDeployOptions, context: Record<string, object>): Trigger;
83
+ //# sourceMappingURL=invoke-on-deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke-on-deploy.d.ts","sourceRoot":"","sources":["../../src/invoke-on-deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAkB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,kDAAkD,CAAC;AA6CnG;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;IACpC,kCAAkC;;IAGlC,oCAAoC;;IAGpC,+BAA+B;;CAEvB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEpC;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,cAAc,EACvB,aAAa,EAAE,UAAU,EACzB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAaT"}