@lambda-kata/cdk 0.1.3-rc.80 → 0.1.3-rc.84
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.
|
Binary file
|
|
@@ -119,6 +119,37 @@ export declare const HANDLER_CONFIG_KEY = "original_js_handler";
|
|
|
119
119
|
* The name of the compiled middleware file within the .kata directory.
|
|
120
120
|
*/
|
|
121
121
|
export declare const MIDDLEWARE_FILE_NAME = "middleware.js";
|
|
122
|
+
/**
|
|
123
|
+
* Bootstrap handler module name.
|
|
124
|
+
* The compiled .pyc is at src/python/dist/kata_bootstrap.pyc and is placed
|
|
125
|
+
* in the config layer at /opt/python/kata_bootstrap.pyc so the Python 3.12
|
|
126
|
+
* runtime resolves it via PYTHONPATH.
|
|
127
|
+
*
|
|
128
|
+
* Using a pre-compiled bootstrap handler prevents SnapStart snapshot failures
|
|
129
|
+
* caused by import errors in the Lambda Kata Layer (C-bridge, Node.js binary, etc.).
|
|
130
|
+
* Source: src/python/kata_bootstrap.py — compiled via `yarn build:python`.
|
|
131
|
+
*/
|
|
132
|
+
export declare const BOOTSTRAP_HANDLER_MODULE = "kata_bootstrap";
|
|
133
|
+
/**
|
|
134
|
+
* Full handler path for the bootstrap handler.
|
|
135
|
+
* Format: "<module>.<function>" as required by Lambda handler configuration.
|
|
136
|
+
*/
|
|
137
|
+
export declare const BOOTSTRAP_HANDLER_PATH = "kata_bootstrap.handler";
|
|
138
|
+
/**
|
|
139
|
+
* Resolves the absolute path to the compiled bootstrap handler .pyc file.
|
|
140
|
+
*
|
|
141
|
+
* Two resolution paths:
|
|
142
|
+
* 1. Production (bundled JS / npm package): out/dist/python/kata_bootstrap.pyc
|
|
143
|
+
* __dirname = out/dist/ → __dirname/python/kata_bootstrap.pyc
|
|
144
|
+
* 2. Development (ts-jest / source): src/python/dist/kata_bootstrap.pyc
|
|
145
|
+
* __dirname = src/ → __dirname/python/dist/kata_bootstrap.pyc
|
|
146
|
+
*
|
|
147
|
+
* @returns Absolute path to kata_bootstrap.pyc
|
|
148
|
+
* @throws Error if the compiled .pyc is not found (build step was skipped)
|
|
149
|
+
*
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
export declare function resolveBootstrapPycPath(): string;
|
|
122
153
|
/**
|
|
123
154
|
* Creates a Lambda Layer containing the kata configuration.
|
|
124
155
|
*
|
package/out/tsc/src/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export { resolveAccountId, resolveAccountIdWithSource, isValidAccountIdFormat, A
|
|
|
24
24
|
export { resolveAccountIdSync, resolveAccountIdSyncWithSource, resolveRegionSync, SyncAccountResolutionError, SyncAccountResolutionResult, SyncAccountResolverOptions, } from './sync-account-resolver';
|
|
25
25
|
export { kata, kataWithAccountId, applyTransformation, handleUnlicensed, isKataTransformed, getKataPromise, extractBundlePathFromHandler, KataWrapperOptions, KataResult, } from './kata-wrapper';
|
|
26
26
|
export { SnapStartActivator, SnapStartActivatorProps, } from './snapstart-construct';
|
|
27
|
-
export { activateSnapStart, SnapStartActivationResult, SnapStartActivatorConfig, } from './snapstart-activator';
|
|
28
|
-
export { createKataConfigLayer, generateConfigContent, KataConfigLayerProps, CONFIG_DIR_NAME, CONFIG_FILE_NAME, HANDLER_CONFIG_KEY, } from './config-layer';
|
|
27
|
+
export { activateSnapStart, handler as snapStartHandler, SnapStartActivationResult, SnapStartActivatorConfig, CustomResourceEvent, CustomResourceResponse, } from './snapstart-activator';
|
|
28
|
+
export { createKataConfigLayer, generateConfigContent, resolveBootstrapPycPath, KataConfigLayerProps, CONFIG_DIR_NAME, CONFIG_FILE_NAME, HANDLER_CONFIG_KEY, BOOTSTRAP_HANDLER_MODULE, BOOTSTRAP_HANDLER_PATH, } from './config-layer';
|
|
29
29
|
export { EnsureNodeRuntimeLayerOptions, EnsureNodeRuntimeLayerResult, NodeVersionInfo, LayerInfo, LayerSearchOptions, LayerRequirements, LayerCreationOptions, Logger, RuntimeDetector, LayerManager, ErrorCodes, NodeRuntimeLayerError, VersionCacheEntry, LayerMetadata, NodejsLayerDeploymentOptions, NodejsLayerDeploymentResult, MultiArchitectureDeploymentResult, } from './nodejs-layer-manager';
|
|
30
30
|
export { DockerRuntimeDetector, DockerRuntimeDetectorOptions, } from './docker-runtime-detector';
|
|
31
31
|
export { AWSLayerManager, AWSLayerManagerOptions, } from './aws-layer-manager';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SnapStart Activator - Custom Resource Handler
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* that enables SnapStart on Lambda functions after deployment. SnapStart requires
|
|
6
|
-
* asynchronous waiting for snapshot creation, which cannot be done during CDK synthesis.
|
|
4
|
+
* Enables SnapStart on Lambda functions after deployment via CloudFormation Custom Resource.
|
|
7
5
|
*
|
|
8
6
|
* The activation process:
|
|
9
7
|
* 1. Wait for function to be Active
|
|
@@ -11,14 +9,11 @@
|
|
|
11
9
|
* 3. Wait for configuration update
|
|
12
10
|
* 4. Publish new version (triggers snapshot creation)
|
|
13
11
|
* 5. Wait for snapshot to be ready (up to 3 minutes)
|
|
14
|
-
* 6. Create/update
|
|
12
|
+
* 6. Create/update alias pointing to the new version — ALWAYS, regardless of snapshot outcome
|
|
15
13
|
*
|
|
16
14
|
* @module snapstart-activator
|
|
17
15
|
*/
|
|
18
16
|
import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
19
|
-
/**
|
|
20
|
-
* Custom Resource event from CloudFormation.
|
|
21
|
-
*/
|
|
22
17
|
export interface CustomResourceEvent {
|
|
23
18
|
RequestType: 'Create' | 'Update' | 'Delete';
|
|
24
19
|
ServiceToken: string;
|
|
@@ -38,9 +33,6 @@ export interface CustomResourceEvent {
|
|
|
38
33
|
AliasName?: string;
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Custom Resource response to CloudFormation.
|
|
43
|
-
*/
|
|
44
36
|
export interface CustomResourceResponse {
|
|
45
37
|
Status: 'SUCCESS' | 'FAILED';
|
|
46
38
|
Reason?: string;
|
|
@@ -55,91 +47,43 @@ export interface CustomResourceResponse {
|
|
|
55
47
|
OptimizationStatus?: string;
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Result of a successful SnapStart activation cycle.
|
|
60
|
-
*
|
|
61
|
-
* Returned by {@link activateSnapStart} after enabling SnapStart,
|
|
62
|
-
* publishing a version, waiting for snapshot readiness, and creating/updating an alias.
|
|
63
|
-
*
|
|
64
|
-
* @see {@link SnapStartActivatorConfig} for configuration options
|
|
65
|
-
*/
|
|
66
50
|
export interface SnapStartActivationResult {
|
|
67
|
-
/** The published Lambda version number (e.g. "42"). */
|
|
68
51
|
version: string;
|
|
69
|
-
/** The alias name that was created or updated (e.g. "kata"). */
|
|
70
52
|
aliasName: string;
|
|
71
|
-
/** The full ARN of the alias (e.g. "arn:aws:lambda:us-east-1:123456789012:function:my-fn:kata"). */
|
|
72
53
|
aliasArn: string;
|
|
73
|
-
/** The SnapStart optimization status of the published version ("On", "Off", or "Unknown"). */
|
|
74
54
|
optimizationStatus: string;
|
|
75
55
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Configuration options for the SnapStart activation cycle.
|
|
78
|
-
*
|
|
79
|
-
* All properties are optional and fall back to sensible defaults.
|
|
80
|
-
*
|
|
81
|
-
* @see {@link activateSnapStart} for the function that consumes this config
|
|
82
|
-
*/
|
|
83
56
|
export interface SnapStartActivatorConfig {
|
|
84
|
-
/**
|
|
85
|
-
* Maximum time in seconds to wait for snapshot creation before proceeding.
|
|
86
|
-
* If exceeded, a warning is logged and alias creation continues.
|
|
87
|
-
* @default 180
|
|
88
|
-
*/
|
|
89
57
|
snapshotTimeoutSeconds?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Interval in seconds between polling attempts for snapshot readiness.
|
|
92
|
-
* @default 2
|
|
93
|
-
*/
|
|
94
58
|
pollingIntervalSeconds?: number;
|
|
95
|
-
/**
|
|
96
|
-
* The Lambda alias name to create or update after publishing a version.
|
|
97
|
-
* @default 'kata'
|
|
98
|
-
*/
|
|
99
59
|
aliasName?: string;
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
* @default 3000
|
|
103
|
-
*/
|
|
104
|
-
_prePublishDelayMs?: number;
|
|
105
|
-
/**
|
|
106
|
-
* @internal Override retry delay in milliseconds (for testing only).
|
|
107
|
-
* @default 5000
|
|
108
|
-
*/
|
|
109
|
-
_retryDelayMs?: number;
|
|
60
|
+
/** @internal */ _prePublishDelayMs?: number;
|
|
61
|
+
/** @internal */ _retryDelayMs?: number;
|
|
110
62
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Sleep for specified milliseconds.
|
|
113
|
-
* @internal Exported for testability — tests can jest.spyOn to avoid real delays.
|
|
114
|
-
*/
|
|
63
|
+
/** @internal Exported for testability — tests can jest.spyOn to avoid real delays. */
|
|
115
64
|
export declare const _testable: {
|
|
116
65
|
sleep(ms: number): Promise<void>;
|
|
117
66
|
};
|
|
118
67
|
/**
|
|
119
68
|
* Activates SnapStart on a Lambda function.
|
|
120
69
|
*
|
|
121
|
-
*
|
|
122
|
-
* 1.
|
|
123
|
-
* 2.
|
|
124
|
-
* 3.
|
|
125
|
-
* 4.
|
|
126
|
-
* 5.
|
|
127
|
-
* 6.
|
|
128
|
-
*
|
|
129
|
-
* Steps 3+4 are wrapped in a retry loop: on State: Failed, a new version
|
|
130
|
-
* is published (up to MAX_PUBLISH_RETRIES attempts) to handle transient
|
|
131
|
-
* initialization failures during snapshot creation.
|
|
70
|
+
* Matches the proven deploy_lambda.py logic:
|
|
71
|
+
* 1. Ensure function is Active
|
|
72
|
+
* 2. Enable SnapStart (ApplyOn: PublishedVersions)
|
|
73
|
+
* 3. Wait for configuration update
|
|
74
|
+
* 4. Publish ONE version
|
|
75
|
+
* 5. Poll until snapshot is Active, Failed, or timeout
|
|
76
|
+
* 6. Create/update alias — ALWAYS, regardless of snapshot outcome
|
|
132
77
|
*
|
|
133
|
-
*
|
|
134
|
-
* @param functionName - Name or ARN of the Lambda function
|
|
135
|
-
* @param config - Optional configuration
|
|
136
|
-
* @returns Activation result with version and alias information
|
|
78
|
+
* No retries. No throws on Failed. Alias is always created.
|
|
137
79
|
*/
|
|
138
80
|
export declare function activateSnapStart(lambdaClient: LambdaClient, functionName: string, config?: SnapStartActivatorConfig): Promise<SnapStartActivationResult>;
|
|
139
81
|
/**
|
|
140
|
-
*
|
|
82
|
+
* Custom Resource handler for CloudFormation.
|
|
141
83
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
84
|
+
* - Delete → SUCCESS immediately (no action)
|
|
85
|
+
* - Create/Update → run activateSnapStart → SUCCESS with data
|
|
86
|
+
* - On error + Update → SUCCESS (prevent rollback deadlock)
|
|
87
|
+
* - On error + Create → FAILED
|
|
144
88
|
*/
|
|
145
89
|
export declare function handler(event: CustomResourceEvent): Promise<CustomResourceResponse>;
|
|
@@ -43,7 +43,7 @@ export interface SnapStartActivatorProps {
|
|
|
43
43
|
* 2. Enables SnapStart configuration (`ApplyOn: PublishedVersions`)
|
|
44
44
|
* 3. Publishes a new version (triggers snapshot creation)
|
|
45
45
|
* 4. Polls until the snapshot is ready (or timeout is reached)
|
|
46
|
-
* 5. Creates or updates an alias pointing to the new version
|
|
46
|
+
* 5. Creates or updates an alias pointing to the new version — ALWAYS, regardless of snapshot outcome
|
|
47
47
|
*
|
|
48
48
|
* After deployment, the published version number and alias ARN are available
|
|
49
49
|
* as CloudFormation attributes via {@link versionRef} and {@link aliasArnRef}.
|
|
@@ -107,6 +107,12 @@ export declare class SnapStartActivator extends Construct {
|
|
|
107
107
|
*
|
|
108
108
|
* This is a self-contained version of the snapstart-activator logic
|
|
109
109
|
* that can be deployed as inline Lambda code.
|
|
110
|
+
*
|
|
111
|
+
* Matches the proven deploy_lambda.py reference:
|
|
112
|
+
* - ONE publish, poll, ALWAYS create alias regardless of snapshot outcome
|
|
113
|
+
* - No retries on Failed state
|
|
114
|
+
* - On Update errors → return SUCCESS (prevent rollback deadlock)
|
|
115
|
+
* - On Create errors → throw (return FAILED)
|
|
110
116
|
*/
|
|
111
117
|
private generateHandlerCode;
|
|
112
118
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambda-kata/cdk",
|
|
3
|
-
"version": "0.1.3-rc.
|
|
3
|
+
"version": "0.1.3-rc.84",
|
|
4
4
|
"description": "AWS CDK integration for Lambda Kata - Node.js Lambdas running via Lambda Kata runtime",
|
|
5
5
|
"main": "out/dist/index.js",
|
|
6
6
|
"types": "out/tsc/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
8
|
+
"build:python": "python3 src/python/compile.py && mkdir -p out/dist/python && cp src/python/dist/kata_bootstrap.pyc out/dist/python/kata_bootstrap.pyc",
|
|
9
|
+
"build": "rm -rf ./dist && rm -rf ./out && rm -rf ./lib && yarn run build:cdk && yarn run types && yarn run build:python",
|
|
9
10
|
"types": "tsc --emitDeclarationOnly && tsc-alias",
|
|
10
11
|
"build:cdk": "yarn run build:config && node dist/utils/build.js --target=cdk",
|
|
11
12
|
"build:minify": "yarn run build:config && node dist/utils/build.js",
|