@composurecdk/lambda 0.9.5 → 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.
- package/LICENSE +21 -0
- package/README.md +177 -0
- package/dist/commonjs/event-sources/dynamodb-event-source.d.ts +10 -4
- package/dist/commonjs/event-sources/dynamodb-event-source.d.ts.map +1 -1
- package/dist/commonjs/event-sources/dynamodb-event-source.js.map +1 -1
- package/dist/commonjs/function-builder.d.ts +79 -7
- package/dist/commonjs/function-builder.d.ts.map +1 -1
- package/dist/commonjs/function-builder.js +83 -4
- package/dist/commonjs/function-builder.js.map +1 -1
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +4 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/invoke-on-deploy.d.ts +83 -0
- package/dist/commonjs/invoke-on-deploy.d.ts.map +1 -0
- package/dist/commonjs/invoke-on-deploy.js +155 -0
- package/dist/commonjs/invoke-on-deploy.js.map +1 -0
- package/dist/esm/event-sources/dynamodb-event-source.d.ts +10 -4
- package/dist/esm/event-sources/dynamodb-event-source.d.ts.map +1 -1
- package/dist/esm/event-sources/dynamodb-event-source.js.map +1 -1
- package/dist/esm/function-builder.d.ts +79 -7
- package/dist/esm/function-builder.d.ts.map +1 -1
- package/dist/esm/function-builder.js +84 -5
- package/dist/esm/function-builder.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/invoke-on-deploy.d.ts +83 -0
- package/dist/esm/invoke-on-deploy.d.ts.map +1 -0
- package/dist/esm/invoke-on-deploy.js +151 -0
- package/dist/esm/invoke-on-deploy.js.map +1 -0
- package/package.json +14 -12
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -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";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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;
|
|
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"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Annotations, Duration } from "aws-cdk-lib";
|
|
2
|
+
import { InvocationType, Trigger } from "aws-cdk-lib/triggers";
|
|
3
|
+
import { addDependencies } from "@composurecdk/core";
|
|
4
|
+
/**
|
|
5
|
+
* Suppression id for the deploy-time invocation timeout guard. Stable and part
|
|
6
|
+
* of the public surface — silence the warning with
|
|
7
|
+
* `Annotations.of(scope).acknowledgeWarning(INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID)`,
|
|
8
|
+
* so it must not be renamed casually.
|
|
9
|
+
*/
|
|
10
|
+
export const INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID = "@composurecdk/lambda:invoke-on-deploy-timeout";
|
|
11
|
+
/**
|
|
12
|
+
* The deployment waits for the handler's response, so a handler that throws
|
|
13
|
+
* fails the stack. An invariant of the action rather than a default: the
|
|
14
|
+
* asynchronous alternative returns before the work happens, reporting success
|
|
15
|
+
* whatever the handler did, so there is nothing to override to.
|
|
16
|
+
*
|
|
17
|
+
* @see https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/rel_tracking_change_management_deployment_management.html
|
|
18
|
+
*/
|
|
19
|
+
const INVOCATION_TYPE = InvocationType.REQUEST_RESPONSE;
|
|
20
|
+
/**
|
|
21
|
+
* The trigger provider's own Lambda timeout. CDK builds that provider from
|
|
22
|
+
* `CustomResourceProviderBase`, which defaults to 15 minutes, and `Trigger`
|
|
23
|
+
* overrides nothing — so there is no seam to raise it through and no way to
|
|
24
|
+
* read it back. Asserted against a synthesised template in the test suite, so
|
|
25
|
+
* an `aws-cdk-lib` upgrade that changes the default fails loudly here rather
|
|
26
|
+
* than quietly reopening the hang this ceiling exists to prevent.
|
|
27
|
+
*/
|
|
28
|
+
const PROVIDER_TIMEOUT = Duration.minutes(15);
|
|
29
|
+
/**
|
|
30
|
+
* Added to the function's own `timeout` to derive the wait, and subtracted
|
|
31
|
+
* from {@link PROVIDER_TIMEOUT} to derive {@link MAX_TIMEOUT} — the same slack
|
|
32
|
+
* at both ends, for the same reason: whoever is waiting must outlive whoever
|
|
33
|
+
* they are waiting for, or the error is never reported.
|
|
34
|
+
*/
|
|
35
|
+
const TIMEOUT_MARGIN = Duration.seconds(30);
|
|
36
|
+
/**
|
|
37
|
+
* Ceiling for the wait. The provider must outlive the invocation it is waiting
|
|
38
|
+
* on, or it dies mid-wait and posts nothing back to CloudFormation. `Trigger`
|
|
39
|
+
* sets no `ServiceTimeout` on the custom resource, so that is not a failed
|
|
40
|
+
* deployment — it is a *hung* one, until CloudFormation abandons the stack
|
|
41
|
+
* operation of its own accord.
|
|
42
|
+
*/
|
|
43
|
+
const MAX_TIMEOUT = PROVIDER_TIMEOUT.minus(TIMEOUT_MARGIN);
|
|
44
|
+
/**
|
|
45
|
+
* The wait applied when the function's own timeout is unset or a token, and so
|
|
46
|
+
* yields no concrete value to derive from. Matches the CDK `Trigger` default.
|
|
47
|
+
*/
|
|
48
|
+
const FALLBACK_TIMEOUT = Duration.minutes(2);
|
|
49
|
+
/**
|
|
50
|
+
* How {@link IFunctionBuilder.invokeOnDeploy | `.invokeOnDeploy()`} derives the
|
|
51
|
+
* wait when the caller sets no {@link InvokeOnDeployOptions.timeout}. A public
|
|
52
|
+
* mirror of this module's constants, exported for visibility and testing — the
|
|
53
|
+
* rationale for each value is on the constant it mirrors.
|
|
54
|
+
*/
|
|
55
|
+
export const INVOKE_ON_DEPLOY_DEFAULTS = {
|
|
56
|
+
/** @see {@link TIMEOUT_MARGIN} */
|
|
57
|
+
timeoutMargin: TIMEOUT_MARGIN,
|
|
58
|
+
/** @see {@link FALLBACK_TIMEOUT} */
|
|
59
|
+
fallbackTimeout: FALLBACK_TIMEOUT,
|
|
60
|
+
/** @see {@link MAX_TIMEOUT} */
|
|
61
|
+
maxTimeout: MAX_TIMEOUT,
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Creates the custom resource that invokes `handler` during deployment and
|
|
65
|
+
* fails the stack if it errors.
|
|
66
|
+
*
|
|
67
|
+
* The invocation is ordered after the function's execution role, so the policies
|
|
68
|
+
* attached *to it* by `.grant()` / `.configureRole()` — which CloudFormation
|
|
69
|
+
* does not otherwise sequence ahead of a custom resource — exist by the time the
|
|
70
|
+
* handler runs.
|
|
71
|
+
*
|
|
72
|
+
* That reaches the identity half of a grant only: one that also writes a
|
|
73
|
+
* resource policy (a KMS key policy, a cross-account bucket policy) leaves that
|
|
74
|
+
* half in the granting resource's tree, and an imported role contributes no
|
|
75
|
+
* resources to sequence at all. Both are the consumer's to declare through
|
|
76
|
+
* {@link InvokeOnDeployOptions.after}, as is anything else the call needs.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export function createDeploymentTrigger(scope, id, handler, executionRole, options, context) {
|
|
81
|
+
const timeout = resolveWait(options.timeout, handler.timeout, id);
|
|
82
|
+
warnOnShortWait(handler, id, timeout);
|
|
83
|
+
const trigger = new Trigger(scope, `${id}DeploymentTrigger`, {
|
|
84
|
+
handler,
|
|
85
|
+
invocationType: INVOCATION_TYPE,
|
|
86
|
+
timeout,
|
|
87
|
+
executeOnHandlerChange: options.executeOnHandlerChange,
|
|
88
|
+
});
|
|
89
|
+
addDependencies(trigger, [executionRole, ...(options.after ?? [])], context);
|
|
90
|
+
return trigger;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* How long the deployment waits.
|
|
94
|
+
*
|
|
95
|
+
* {@link MAX_TIMEOUT} binds both branches, but differently. A derived wait is
|
|
96
|
+
* capped: the derivation is the library's, so quietly settling for less than it
|
|
97
|
+
* wanted is the library's business. An explicit wait over the ceiling throws —
|
|
98
|
+
* clamping would honour neither the duration the caller asked for nor the
|
|
99
|
+
* failing deployment they expected, and there is no working form to fall back
|
|
100
|
+
* to. Both are silent on a token, which has no value to compare.
|
|
101
|
+
*/
|
|
102
|
+
function resolveWait(explicitWait, handlerTimeout, id) {
|
|
103
|
+
if (explicitWait !== undefined) {
|
|
104
|
+
const waitSeconds = concreteSeconds(explicitWait);
|
|
105
|
+
if (waitSeconds !== undefined && waitSeconds > MAX_TIMEOUT.toSeconds()) {
|
|
106
|
+
throw new Error(`FunctionBuilder "${id}": .invokeOnDeploy() was given a timeout of ${String(waitSeconds)}s, ` +
|
|
107
|
+
`but the deployment cannot wait longer than ${String(MAX_TIMEOUT.toSeconds())}s — CDK's ` +
|
|
108
|
+
`trigger provider runs with a ${String(PROVIDER_TIMEOUT.toSeconds())}s Lambda timeout ` +
|
|
109
|
+
`and needs the remainder to report the result. A longer wait does not fail the ` +
|
|
110
|
+
`deployment, it hangs it: the provider dies mid-invocation and CloudFormation is never ` +
|
|
111
|
+
`told. Lower the timeout, or move work that needs longer out of the deployment.`);
|
|
112
|
+
}
|
|
113
|
+
return explicitWait;
|
|
114
|
+
}
|
|
115
|
+
const handlerSeconds = concreteSeconds(handlerTimeout);
|
|
116
|
+
if (handlerSeconds === undefined)
|
|
117
|
+
return FALLBACK_TIMEOUT;
|
|
118
|
+
const derived = handlerSeconds + TIMEOUT_MARGIN.toSeconds();
|
|
119
|
+
return Duration.seconds(Math.min(derived, MAX_TIMEOUT.toSeconds()));
|
|
120
|
+
}
|
|
121
|
+
/** A `Duration` in seconds, or `undefined` when it is unset or a token. */
|
|
122
|
+
function concreteSeconds(duration) {
|
|
123
|
+
if (duration === undefined || duration.isUnresolved())
|
|
124
|
+
return undefined;
|
|
125
|
+
return duration.toSeconds();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Warns when the deployment would stop waiting before the handler's own timeout
|
|
129
|
+
* — a handler that runs long then fails the stack as an abandoned invocation
|
|
130
|
+
* rather than reporting the error it was about to produce.
|
|
131
|
+
*
|
|
132
|
+
* Checked against the final wait, whether the caller set it or it was derived,
|
|
133
|
+
* because the derived path can land here too: the cap leaves no margin once the
|
|
134
|
+
* function's own timeout reaches {@link MAX_TIMEOUT}.
|
|
135
|
+
* Silent whenever either value is a token, with nothing to compare.
|
|
136
|
+
*/
|
|
137
|
+
function warnOnShortWait(handler, id, wait) {
|
|
138
|
+
const waitSeconds = concreteSeconds(wait);
|
|
139
|
+
const handlerSeconds = concreteSeconds(handler.timeout);
|
|
140
|
+
if (waitSeconds === undefined || handlerSeconds === undefined)
|
|
141
|
+
return;
|
|
142
|
+
if (waitSeconds > handlerSeconds)
|
|
143
|
+
return;
|
|
144
|
+
Annotations.of(handler).addWarningV2(INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID, `FunctionBuilder "${id}": .invokeOnDeploy() waits ${String(waitSeconds)}s but the function's ` +
|
|
145
|
+
`own timeout is ${String(handlerSeconds)}s — the deployment stops waiting while the handler ` +
|
|
146
|
+
`is still running, so a slow call fails the stack as an abandoned invocation instead of ` +
|
|
147
|
+
`reporting the handler's error. Give the deployment longer than the function's timeout (up ` +
|
|
148
|
+
`to ${String(MAX_TIMEOUT.toSeconds())}s), shorten the function's ` +
|
|
149
|
+
`timeout, or acknowledge "${INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID}".`);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=invoke-on-deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke-on-deploy.js","sourceRoot":"","sources":["../../src/invoke-on-deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAyB,MAAM,oBAAoB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,+CAA+C,CAAC;AAEnG;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,cAAc,CAAC,gBAAgB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,kCAAkC;IAClC,aAAa,EAAE,cAAc;IAE7B,oCAAoC;IACpC,eAAe,EAAE,gBAAgB;IAEjC,+BAA+B;I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@composurecdk/lambda",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Composable Lambda function builder with well-architected defaults",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/laazyj/composureCDK",
|
|
7
|
+
"url": "git+https://github.com/laazyj/composureCDK.git",
|
|
8
8
|
"directory": "packages/lambda"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -48,21 +48,23 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@composurecdk/cloudformation": "^0.
|
|
52
|
-
"@composurecdk/cloudwatch": "^0.
|
|
53
|
-
"@composurecdk/core": "^0.
|
|
54
|
-
"@composurecdk/iam": "^0.
|
|
55
|
-
"@composurecdk/logs": "^0.
|
|
51
|
+
"@composurecdk/cloudformation": "^0.10.0",
|
|
52
|
+
"@composurecdk/cloudwatch": "^0.10.0",
|
|
53
|
+
"@composurecdk/core": "^0.10.0",
|
|
54
|
+
"@composurecdk/iam": "^0.10.0",
|
|
55
|
+
"@composurecdk/logs": "^0.10.0",
|
|
56
56
|
"aws-cdk-lib": "^2.168.0",
|
|
57
57
|
"constructs": "^10.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@composurecdk/
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
63
|
-
"
|
|
60
|
+
"@composurecdk/cdk-testing": "*",
|
|
61
|
+
"@composurecdk/iam": "^0.10.0",
|
|
62
|
+
"@types/node": "^26.6.1",
|
|
63
|
+
"aws-cdk-lib": "^2.269.0",
|
|
64
|
+
"constructs": "^10.8.1",
|
|
65
|
+
"ts-fake": "^1.2.0",
|
|
64
66
|
"typescript": "^6.0.3",
|
|
65
|
-
"vitest": "^
|
|
67
|
+
"vitest": "^5.0.0"
|
|
66
68
|
},
|
|
67
69
|
"exports": {
|
|
68
70
|
"./package.json": "./package.json",
|