@lambda-kata/cdk 0.1.3-rc.1 → 0.1.3-rc.10
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/out/dist/index.js +110 -51
- package/out/tsc/src/aws-layer-manager.d.ts +493 -0
- package/out/tsc/src/docker-runtime-detector.d.ts +168 -0
- package/out/tsc/src/ensure-node-runtime-layer.d.ts +42 -0
- package/out/tsc/src/index.d.ts +5 -0
- package/out/tsc/src/kata-wrapper.d.ts +27 -14
- package/out/tsc/src/logger.d.ts +88 -0
- package/out/tsc/src/nodejs-layer-manager.d.ts +419 -0
- package/package.json +7 -6
package/out/tsc/src/index.d.ts
CHANGED
|
@@ -23,3 +23,8 @@ export { MockLicensingService, createMockLicensingService, } from './mock-licens
|
|
|
23
23
|
export { resolveAccountId, resolveAccountIdWithSource, isValidAccountIdFormat, AccountResolutionError, AccountResolutionResult, AccountResolverOptions, } from './account-resolver';
|
|
24
24
|
export { kata, kataWithAccountId, applyTransformation, handleUnlicensed, isKataTransformed, getKataPromise, KataWrapperOptions, KataResult, } from './kata-wrapper';
|
|
25
25
|
export { createKataConfigLayer, generateConfigContent, KataConfigLayerProps, CONFIG_DIR_NAME, CONFIG_FILE_NAME, HANDLER_CONFIG_KEY, } from './config-layer';
|
|
26
|
+
export { EnsureNodeRuntimeLayerOptions, EnsureNodeRuntimeLayerResult, NodeVersionInfo, LayerInfo, LayerSearchOptions, LayerRequirements, LayerCreationOptions, Logger, RuntimeDetector, LayerManager, ErrorCodes, NodeRuntimeLayerError, VersionCacheEntry, LayerMetadata, } from './nodejs-layer-manager';
|
|
27
|
+
export { DockerRuntimeDetector, DockerRuntimeDetectorOptions, } from './docker-runtime-detector';
|
|
28
|
+
export { AWSLayerManager, AWSLayerManagerOptions, } from './aws-layer-manager';
|
|
29
|
+
export { NoOpLogger, ConsoleLogger, createDefaultLogger, OperationTimer, } from './logger';
|
|
30
|
+
export { ensureNodeRuntimeLayer } from './ensure-node-runtime-layer';
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kata Wrapper for Lambda Kata CDK Integration
|
|
3
|
-
*
|
|
4
|
-
* This module provides the main `kata()` function that transforms Node.js Lambda
|
|
5
|
-
* functions to run via the Lambda Kata runtime. The transformation includes:
|
|
6
|
-
* - Changing the runtime to Python 3.12
|
|
7
|
-
* - Setting the handler to the Lambda Kata handler
|
|
8
|
-
* - Attaching the customer-specific Lambda Layer
|
|
9
|
-
* - Preserving the original handler path in a config layer
|
|
10
|
-
*
|
|
11
|
-
* Licensing is validated at CDK synthesis/deploy time only—no runtime network calls.
|
|
12
|
-
*
|
|
13
|
-
* @module kata-wrapper
|
|
14
|
-
*/
|
|
15
1
|
import { Function as LambdaFunction } from 'aws-cdk-lib/aws-lambda';
|
|
16
2
|
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
17
3
|
import { KataProps, LicensingResponse, TransformationConfig } from './types';
|
|
@@ -130,6 +116,33 @@ export declare function kata<T extends NodejsFunction | LambdaFunction>(lambda:
|
|
|
130
116
|
* @internal
|
|
131
117
|
*/
|
|
132
118
|
export declare function kataWithAccountId<T extends NodejsFunction | LambdaFunction>(lambda: T, accountId: string, props?: KataWrapperOptions): Promise<KataResult>;
|
|
119
|
+
/**
|
|
120
|
+
* Gets the original runtime from a Lambda function before transformation.
|
|
121
|
+
*
|
|
122
|
+
* @param lambda - The Lambda function
|
|
123
|
+
* @returns The original runtime name (e.g., "nodejs20.x")
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare function getOriginalRuntime(lambda: NodejsFunction | LambdaFunction): string;
|
|
128
|
+
/**
|
|
129
|
+
* Detects if a Lambda function uses a Node.js runtime.
|
|
130
|
+
*
|
|
131
|
+
* @param lambda - The Lambda function to check
|
|
132
|
+
* @returns true if the function uses a supported Node.js runtime
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export declare function isNodejsRuntime(lambda: NodejsFunction | LambdaFunction): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Gets the architecture of a Lambda function.
|
|
139
|
+
*
|
|
140
|
+
* @param lambda - The Lambda function
|
|
141
|
+
* @returns The architecture ("x86_64" or "arm64")
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
export declare function getLambdaArchitecture(lambda: NodejsFunction | LambdaFunction): 'x86_64' | 'arm64';
|
|
133
146
|
/**
|
|
134
147
|
* Applies the Lambda Kata transformation to a Lambda function.
|
|
135
148
|
*
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger implementations for Node.js Layer Management
|
|
3
|
+
*
|
|
4
|
+
* Provides different logger implementations for various use cases:
|
|
5
|
+
* - NoOpLogger: Silent logger for production use
|
|
6
|
+
* - ConsoleLogger: Console-based logger for development and debugging
|
|
7
|
+
*
|
|
8
|
+
* @module logger
|
|
9
|
+
*/
|
|
10
|
+
import { Logger } from './nodejs-layer-manager';
|
|
11
|
+
/**
|
|
12
|
+
* No-operation logger that silently discards all log messages.
|
|
13
|
+
*
|
|
14
|
+
* This is the default logger used when no custom logger is provided.
|
|
15
|
+
* Useful for production environments where logging overhead should be minimized.
|
|
16
|
+
*/
|
|
17
|
+
export declare class NoOpLogger implements Logger {
|
|
18
|
+
debug(_message: string, _meta?: Record<string, unknown>): void;
|
|
19
|
+
info(_message: string, _meta?: Record<string, unknown>): void;
|
|
20
|
+
warn(_message: string, _meta?: Record<string, unknown>): void;
|
|
21
|
+
error(_message: string, _meta?: Record<string, unknown>): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Console-based logger for development and debugging.
|
|
25
|
+
*
|
|
26
|
+
* Outputs structured log messages to the console with timestamps and metadata.
|
|
27
|
+
* Useful for development environments and troubleshooting.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ConsoleLogger implements Logger {
|
|
30
|
+
private readonly prefix;
|
|
31
|
+
private readonly logLevel;
|
|
32
|
+
constructor(prefix?: string, logLevel?: 'debug' | 'info' | 'warn' | 'error');
|
|
33
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
34
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
35
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
36
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
37
|
+
private shouldLog;
|
|
38
|
+
private log;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a default logger instance.
|
|
42
|
+
*
|
|
43
|
+
* Returns a NoOpLogger by default, but can be configured to return
|
|
44
|
+
* a ConsoleLogger based on environment variables or other configuration.
|
|
45
|
+
*
|
|
46
|
+
* @returns A logger instance
|
|
47
|
+
*/
|
|
48
|
+
export declare function createDefaultLogger(): Logger;
|
|
49
|
+
/**
|
|
50
|
+
* Utility class for measuring operation timing with structured logging.
|
|
51
|
+
*
|
|
52
|
+
* Provides consistent timing measurement and logging across all operations.
|
|
53
|
+
* Ensures operation start/completion logging with timing information.
|
|
54
|
+
*/
|
|
55
|
+
export declare class OperationTimer {
|
|
56
|
+
private readonly startTime;
|
|
57
|
+
private readonly logger;
|
|
58
|
+
private readonly operationType;
|
|
59
|
+
private readonly operationMetadata;
|
|
60
|
+
constructor(logger: Logger, operationType: string, operationMetadata?: Record<string, unknown>);
|
|
61
|
+
/**
|
|
62
|
+
* Completes the operation timing and logs success.
|
|
63
|
+
*
|
|
64
|
+
* @param resultMetadata - Additional metadata about the operation result
|
|
65
|
+
*/
|
|
66
|
+
complete(resultMetadata?: Record<string, unknown>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Completes the operation timing and logs failure.
|
|
69
|
+
*
|
|
70
|
+
* @param error - The error that caused the operation to fail
|
|
71
|
+
* @param errorMetadata - Additional metadata about the error
|
|
72
|
+
*/
|
|
73
|
+
fail(error: unknown, errorMetadata?: Record<string, unknown>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Extracts AWS request ID from error objects.
|
|
76
|
+
*
|
|
77
|
+
* @param error - The error to extract request ID from
|
|
78
|
+
* @returns AWS request ID if found, undefined otherwise
|
|
79
|
+
*/
|
|
80
|
+
private extractAwsRequestId;
|
|
81
|
+
/**
|
|
82
|
+
* Generates troubleshooting context based on error type.
|
|
83
|
+
*
|
|
84
|
+
* @param error - The error to generate context for
|
|
85
|
+
* @returns Troubleshooting guidance
|
|
86
|
+
*/
|
|
87
|
+
private generateTroubleshootingContext;
|
|
88
|
+
}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js Runtime-Aware Lambda Layer Management
|
|
3
|
+
*
|
|
4
|
+
* This module provides TypeScript-only orchestration for detecting Node.js Lambda
|
|
5
|
+
* runtime versions and managing corresponding Node.js Lambda Layers. The system
|
|
6
|
+
* automatically ensures the correct Node.js binaries are available at execution time
|
|
7
|
+
* by creating or reusing Lambda Layers that contain Node.js runtime binaries matching
|
|
8
|
+
* the exact versions used in AWS Lambda runtime images.
|
|
9
|
+
*
|
|
10
|
+
* Key features:
|
|
11
|
+
* - Detects exact Node.js versions from AWS Lambda Docker images
|
|
12
|
+
* - Creates minimal Lambda Layers with only Node.js binaries
|
|
13
|
+
* - Supports both x86_64 and arm64 architectures
|
|
14
|
+
* - Implements idempotent operations with layer reuse
|
|
15
|
+
* - Provides comprehensive error handling and logging
|
|
16
|
+
*
|
|
17
|
+
* @module nodejs-layer-manager
|
|
18
|
+
*/
|
|
19
|
+
import { LambdaClientConfig } from '@aws-sdk/client-lambda';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options for ensuring a Node.js runtime layer exists.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const options: EnsureNodeRuntimeLayerOptions = {
|
|
26
|
+
* runtimeName: 'nodejs20.x',
|
|
27
|
+
* architecture: 'x86_64',
|
|
28
|
+
* region: 'us-east-1',
|
|
29
|
+
* accountId: '123456789012'
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface EnsureNodeRuntimeLayerOptions {
|
|
34
|
+
/**
|
|
35
|
+
* The AWS Lambda runtime name (e.g., "nodejs18.x", "nodejs20.x", "nodejs22.x").
|
|
36
|
+
* This determines which Node.js major version to use.
|
|
37
|
+
*/
|
|
38
|
+
runtimeName: string;
|
|
39
|
+
/**
|
|
40
|
+
* The target architecture for the Lambda function and layer.
|
|
41
|
+
* Must be either "x86_64" or "arm64".
|
|
42
|
+
*/
|
|
43
|
+
architecture: 'x86_64' | 'arm64';
|
|
44
|
+
/**
|
|
45
|
+
* The AWS region where the layer should be created or found.
|
|
46
|
+
*/
|
|
47
|
+
region: string;
|
|
48
|
+
/**
|
|
49
|
+
* The AWS account ID where the layer should be created or found.
|
|
50
|
+
*/
|
|
51
|
+
accountId: string;
|
|
52
|
+
/**
|
|
53
|
+
* Optional AWS SDK configuration for custom authentication, region, or endpoint settings.
|
|
54
|
+
* If not provided, the default AWS SDK configuration will be used.
|
|
55
|
+
*/
|
|
56
|
+
awsSdkConfig?: LambdaClientConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Optional logger for debugging and monitoring layer operations.
|
|
59
|
+
* If not provided, a no-op logger will be used.
|
|
60
|
+
*/
|
|
61
|
+
logger?: Logger;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Result of ensuring a Node.js runtime layer exists.
|
|
65
|
+
*
|
|
66
|
+
* Contains all information about the layer that was created or found,
|
|
67
|
+
* including metadata for debugging and monitoring.
|
|
68
|
+
*/
|
|
69
|
+
export interface EnsureNodeRuntimeLayerResult {
|
|
70
|
+
/**
|
|
71
|
+
* The ARN of the Lambda Layer that contains the Node.js runtime.
|
|
72
|
+
* This ARN can be attached to Lambda functions.
|
|
73
|
+
*/
|
|
74
|
+
layerArn: string;
|
|
75
|
+
/**
|
|
76
|
+
* The name of the Lambda Layer.
|
|
77
|
+
* Follows the pattern: lambda-kata-nodejs-${runtimeName}-${architecture}
|
|
78
|
+
*/
|
|
79
|
+
layerName: string;
|
|
80
|
+
/**
|
|
81
|
+
* The original runtime name that was requested.
|
|
82
|
+
*/
|
|
83
|
+
runtimeName: string;
|
|
84
|
+
/**
|
|
85
|
+
* The exact Node.js version detected from the AWS Lambda runtime image.
|
|
86
|
+
* Format: semantic version string (e.g., "20.10.0")
|
|
87
|
+
*/
|
|
88
|
+
nodeVersion: string;
|
|
89
|
+
/**
|
|
90
|
+
* The architecture of the layer and Node.js binary.
|
|
91
|
+
*/
|
|
92
|
+
architecture: 'x86_64' | 'arm64';
|
|
93
|
+
/**
|
|
94
|
+
* Whether a new layer was created (true) or an existing layer was reused (false).
|
|
95
|
+
* Useful for monitoring and debugging layer management operations.
|
|
96
|
+
*/
|
|
97
|
+
created: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Information about a detected Node.js version from AWS Lambda runtime images.
|
|
101
|
+
*
|
|
102
|
+
* This interface represents the result of querying AWS Lambda Docker images
|
|
103
|
+
* to determine the exact Node.js version used by a specific runtime.
|
|
104
|
+
*/
|
|
105
|
+
export interface NodeVersionInfo {
|
|
106
|
+
/**
|
|
107
|
+
* The exact Node.js version string (e.g., "20.10.0").
|
|
108
|
+
* Extracted from `node --version` within the AWS Lambda runtime Docker image.
|
|
109
|
+
*/
|
|
110
|
+
version: string;
|
|
111
|
+
/**
|
|
112
|
+
* The original runtime name that was queried.
|
|
113
|
+
*/
|
|
114
|
+
runtimeName: string;
|
|
115
|
+
/**
|
|
116
|
+
* The Docker image that was used to detect the version.
|
|
117
|
+
* Format: public.ecr.aws/lambda/nodejs:{majorVersion}-{architecture}
|
|
118
|
+
*/
|
|
119
|
+
dockerImage: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Information about a Lambda Layer containing Node.js runtime.
|
|
123
|
+
*
|
|
124
|
+
* This interface represents metadata about existing or newly created
|
|
125
|
+
* Node.js Lambda Layers for compatibility checking and management.
|
|
126
|
+
*/
|
|
127
|
+
export interface LayerInfo {
|
|
128
|
+
/**
|
|
129
|
+
* The full ARN of the Lambda Layer version.
|
|
130
|
+
*/
|
|
131
|
+
arn: string;
|
|
132
|
+
/**
|
|
133
|
+
* The name of the Lambda Layer.
|
|
134
|
+
*/
|
|
135
|
+
name: string;
|
|
136
|
+
/**
|
|
137
|
+
* The version number of the Lambda Layer.
|
|
138
|
+
*/
|
|
139
|
+
version: number;
|
|
140
|
+
/**
|
|
141
|
+
* The Node.js version contained in this layer.
|
|
142
|
+
*/
|
|
143
|
+
nodeVersion: string;
|
|
144
|
+
/**
|
|
145
|
+
* The architecture this layer is compatible with.
|
|
146
|
+
*/
|
|
147
|
+
architecture: string;
|
|
148
|
+
/**
|
|
149
|
+
* When this layer version was created.
|
|
150
|
+
*/
|
|
151
|
+
createdDate: Date;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Options for searching existing Lambda Layers.
|
|
155
|
+
*
|
|
156
|
+
* Used internally by LayerManager to find compatible existing layers.
|
|
157
|
+
*/
|
|
158
|
+
export interface LayerSearchOptions {
|
|
159
|
+
/**
|
|
160
|
+
* The expected layer name to search for.
|
|
161
|
+
*/
|
|
162
|
+
layerName: string;
|
|
163
|
+
/**
|
|
164
|
+
* Requirements that the layer must meet to be considered compatible.
|
|
165
|
+
*/
|
|
166
|
+
requirements: LayerRequirements;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Requirements that a Lambda Layer must meet to be considered compatible.
|
|
170
|
+
*
|
|
171
|
+
* Used for validating whether an existing layer can be reused.
|
|
172
|
+
*/
|
|
173
|
+
export interface LayerRequirements {
|
|
174
|
+
/**
|
|
175
|
+
* The required Node.js version.
|
|
176
|
+
*/
|
|
177
|
+
nodeVersion: string;
|
|
178
|
+
/**
|
|
179
|
+
* The required architecture.
|
|
180
|
+
*/
|
|
181
|
+
architecture: string;
|
|
182
|
+
/**
|
|
183
|
+
* Maximum age for the layer to be considered fresh.
|
|
184
|
+
* Layers older than this may be recreated.
|
|
185
|
+
*/
|
|
186
|
+
maxAge?: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Options for creating a new Lambda Layer.
|
|
190
|
+
*
|
|
191
|
+
* Contains all information needed to build and publish a Node.js layer.
|
|
192
|
+
*/
|
|
193
|
+
export interface LayerCreationOptions {
|
|
194
|
+
/**
|
|
195
|
+
* The name for the new layer.
|
|
196
|
+
*/
|
|
197
|
+
layerName: string;
|
|
198
|
+
/**
|
|
199
|
+
* The Node.js version to include in the layer.
|
|
200
|
+
*/
|
|
201
|
+
nodeVersion: string;
|
|
202
|
+
/**
|
|
203
|
+
* The target architecture.
|
|
204
|
+
*/
|
|
205
|
+
architecture: 'x86_64' | 'arm64';
|
|
206
|
+
/**
|
|
207
|
+
* The AWS region where the layer should be created.
|
|
208
|
+
*/
|
|
209
|
+
region: string;
|
|
210
|
+
/**
|
|
211
|
+
* Optional description for the layer.
|
|
212
|
+
*/
|
|
213
|
+
description?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Logger interface for debugging and monitoring layer operations.
|
|
217
|
+
*
|
|
218
|
+
* Provides structured logging with different severity levels and optional metadata.
|
|
219
|
+
*/
|
|
220
|
+
export interface Logger {
|
|
221
|
+
/**
|
|
222
|
+
* Log debug information for detailed troubleshooting.
|
|
223
|
+
*/
|
|
224
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
225
|
+
/**
|
|
226
|
+
* Log informational messages about normal operations.
|
|
227
|
+
*/
|
|
228
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
229
|
+
/**
|
|
230
|
+
* Log warning messages about potential issues.
|
|
231
|
+
*/
|
|
232
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
233
|
+
/**
|
|
234
|
+
* Log error messages about failures and exceptions.
|
|
235
|
+
*/
|
|
236
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Interface for detecting Node.js versions from AWS Lambda runtime images.
|
|
240
|
+
*
|
|
241
|
+
* Implementations should use Docker to pull AWS Lambda runtime images
|
|
242
|
+
* and extract the exact Node.js version using `node --version`.
|
|
243
|
+
*/
|
|
244
|
+
export interface RuntimeDetector {
|
|
245
|
+
/**
|
|
246
|
+
* Detects the exact Node.js version for a given runtime and architecture.
|
|
247
|
+
*
|
|
248
|
+
* @param runtimeName - The AWS Lambda runtime (e.g., "nodejs20.x")
|
|
249
|
+
* @param architecture - The target architecture ("x86_64" or "arm64")
|
|
250
|
+
* @returns Promise resolving to Node.js version information
|
|
251
|
+
* @throws NodeRuntimeLayerError if detection fails
|
|
252
|
+
*/
|
|
253
|
+
detectNodeVersion(runtimeName: string, architecture: string): Promise<NodeVersionInfo>;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Interface for managing Lambda Layers containing Node.js runtime.
|
|
257
|
+
*
|
|
258
|
+
* Implementations should handle layer creation, searching, and compatibility validation
|
|
259
|
+
* using AWS SDK v3 Lambda client operations.
|
|
260
|
+
*/
|
|
261
|
+
export interface LayerManager {
|
|
262
|
+
/**
|
|
263
|
+
* Searches for an existing compatible Node.js layer.
|
|
264
|
+
*
|
|
265
|
+
* @param options - Search criteria and requirements
|
|
266
|
+
* @returns Promise resolving to layer info if found, null otherwise
|
|
267
|
+
* @throws NodeRuntimeLayerError if search fails
|
|
268
|
+
*/
|
|
269
|
+
findExistingLayer(options: LayerSearchOptions): Promise<LayerInfo | null>;
|
|
270
|
+
/**
|
|
271
|
+
* Creates a new Node.js Lambda Layer.
|
|
272
|
+
*
|
|
273
|
+
* @param options - Layer creation configuration
|
|
274
|
+
* @returns Promise resolving to information about the created layer
|
|
275
|
+
* @throws NodeRuntimeLayerError if creation fails
|
|
276
|
+
*/
|
|
277
|
+
createNodeLayer(options: LayerCreationOptions): Promise<LayerInfo>;
|
|
278
|
+
/**
|
|
279
|
+
* Validates whether a layer meets the specified requirements.
|
|
280
|
+
*
|
|
281
|
+
* @param layer - The layer to validate
|
|
282
|
+
* @param requirements - The requirements to check against
|
|
283
|
+
* @returns true if the layer is compatible, false otherwise
|
|
284
|
+
*/
|
|
285
|
+
validateLayerCompatibility(layer: LayerInfo, requirements: LayerRequirements): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Gets the current circuit breaker state for monitoring and debugging.
|
|
288
|
+
*
|
|
289
|
+
* @returns Object containing circuit breaker state information
|
|
290
|
+
*/
|
|
291
|
+
getCircuitBreakerState(): {
|
|
292
|
+
state: string;
|
|
293
|
+
failureCount: number;
|
|
294
|
+
successCount: number;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Destroys the layer manager and cleans up resources.
|
|
298
|
+
*
|
|
299
|
+
* Should be called when the manager is no longer needed to prevent
|
|
300
|
+
* resource leaks.
|
|
301
|
+
*/
|
|
302
|
+
destroy(): void;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Error codes for Node.js runtime layer management operations.
|
|
306
|
+
*
|
|
307
|
+
* These codes provide structured error classification for different failure scenarios.
|
|
308
|
+
*/
|
|
309
|
+
export declare enum ErrorCodes {
|
|
310
|
+
/**
|
|
311
|
+
* Docker is not available or cannot be executed.
|
|
312
|
+
*/
|
|
313
|
+
DOCKER_UNAVAILABLE = "DOCKER_UNAVAILABLE",
|
|
314
|
+
/**
|
|
315
|
+
* The specified runtime is not supported.
|
|
316
|
+
*/
|
|
317
|
+
RUNTIME_UNSUPPORTED = "RUNTIME_UNSUPPORTED",
|
|
318
|
+
/**
|
|
319
|
+
* AWS API operation failed.
|
|
320
|
+
*/
|
|
321
|
+
AWS_API_ERROR = "AWS_API_ERROR",
|
|
322
|
+
/**
|
|
323
|
+
* Layer creation operation failed.
|
|
324
|
+
*/
|
|
325
|
+
LAYER_CREATION_FAILED = "LAYER_CREATION_FAILED",
|
|
326
|
+
/**
|
|
327
|
+
* The specified architecture is not supported.
|
|
328
|
+
*/
|
|
329
|
+
INVALID_ARCHITECTURE = "INVALID_ARCHITECTURE",
|
|
330
|
+
/**
|
|
331
|
+
* Node.js version detection failed.
|
|
332
|
+
*/
|
|
333
|
+
VERSION_DETECTION_FAILED = "VERSION_DETECTION_FAILED",
|
|
334
|
+
/**
|
|
335
|
+
* Layer size exceeds AWS limits.
|
|
336
|
+
*/
|
|
337
|
+
LAYER_SIZE_EXCEEDED = "LAYER_SIZE_EXCEEDED",
|
|
338
|
+
/**
|
|
339
|
+
* AWS account quota exceeded.
|
|
340
|
+
*/
|
|
341
|
+
QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
|
|
342
|
+
/**
|
|
343
|
+
* Internal error or unexpected failure.
|
|
344
|
+
*/
|
|
345
|
+
INTERNAL_ERROR = "INTERNAL_ERROR"
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Specialized error class for Node.js runtime layer management operations.
|
|
349
|
+
*
|
|
350
|
+
* Provides structured error information with error codes, descriptive messages,
|
|
351
|
+
* and optional cause chaining for debugging.
|
|
352
|
+
*/
|
|
353
|
+
export declare class NodeRuntimeLayerError extends Error {
|
|
354
|
+
readonly code: ErrorCodes;
|
|
355
|
+
readonly cause?: Error | undefined;
|
|
356
|
+
/**
|
|
357
|
+
* Creates a new NodeRuntimeLayerError.
|
|
358
|
+
*
|
|
359
|
+
* @param message - Human-readable error message
|
|
360
|
+
* @param code - Structured error code for programmatic handling
|
|
361
|
+
* @param cause - Optional underlying error that caused this error
|
|
362
|
+
*/
|
|
363
|
+
constructor(message: string, code: ErrorCodes, cause?: Error | undefined);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Cache entry for storing detected Node.js version information.
|
|
367
|
+
*
|
|
368
|
+
* Used internally to avoid repeated Docker operations for the same runtime.
|
|
369
|
+
*/
|
|
370
|
+
export interface VersionCacheEntry {
|
|
371
|
+
/**
|
|
372
|
+
* The detected Node.js version.
|
|
373
|
+
*/
|
|
374
|
+
version: string;
|
|
375
|
+
/**
|
|
376
|
+
* The runtime name that was queried.
|
|
377
|
+
*/
|
|
378
|
+
runtimeName: string;
|
|
379
|
+
/**
|
|
380
|
+
* The Docker image that was used.
|
|
381
|
+
*/
|
|
382
|
+
dockerImage: string;
|
|
383
|
+
/**
|
|
384
|
+
* When this entry was cached.
|
|
385
|
+
*/
|
|
386
|
+
cachedAt: Date;
|
|
387
|
+
/**
|
|
388
|
+
* Time-to-live in milliseconds.
|
|
389
|
+
*/
|
|
390
|
+
ttl: number;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Metadata for Lambda Layer creation and management.
|
|
394
|
+
*
|
|
395
|
+
* Contains information needed for AWS Lambda Layer operations.
|
|
396
|
+
*/
|
|
397
|
+
export interface LayerMetadata {
|
|
398
|
+
/**
|
|
399
|
+
* The name of the Lambda Layer.
|
|
400
|
+
*/
|
|
401
|
+
layerName: string;
|
|
402
|
+
/**
|
|
403
|
+
* Human-readable description of the layer.
|
|
404
|
+
*/
|
|
405
|
+
description: string;
|
|
406
|
+
/**
|
|
407
|
+
* Compatible Lambda runtimes.
|
|
408
|
+
* For Lambda Kata, this is typically ["python3.12"].
|
|
409
|
+
*/
|
|
410
|
+
compatibleRuntimes: string[];
|
|
411
|
+
/**
|
|
412
|
+
* Compatible architectures.
|
|
413
|
+
*/
|
|
414
|
+
compatibleArchitectures: string[];
|
|
415
|
+
/**
|
|
416
|
+
* Optional license information.
|
|
417
|
+
*/
|
|
418
|
+
licenseInfo?: string;
|
|
419
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambda-kata/cdk",
|
|
3
|
-
"version": "0.1.3-rc.
|
|
3
|
+
"version": "0.1.3-rc.10",
|
|
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",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"build:minify": "yarn run build:config && node dist/utils/build.js",
|
|
12
12
|
"build:config": "esbuild --bundle --platform=node utils/esbuild/esbuild.build.ts --outfile=dist/utils/build.js --external:esbuild",
|
|
13
13
|
"watch": "tsc -w",
|
|
14
|
-
"test": "jest",
|
|
15
|
-
"test:watch": "jest --watch",
|
|
14
|
+
"test": "npx jest --runInBand --colors --verbose --testTimeout=30000 --forceExit --detectOpenHandles",
|
|
15
|
+
"test:watch": "npx jest --watch --testTimeout=30000 --runInBand",
|
|
16
16
|
"lint": "eslint src/ test/ --ext .ts",
|
|
17
17
|
"clean": "rm -rf lib coverage",
|
|
18
18
|
"docs": "yarn run docs:md && yarn run docs:html",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"types": "./out/tsc/index.d.ts",
|
|
29
|
+
"types": "./out/tsc/src/index.d.ts",
|
|
30
30
|
"default": "./out/dist/index.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"python",
|
|
40
40
|
"serverless"
|
|
41
41
|
],
|
|
42
|
-
"author": "
|
|
42
|
+
"author": "Raman Marozau, raman@worktif.com",
|
|
43
43
|
"license": "Apache-2.0",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
|
-
"url": "https://github.com/
|
|
46
|
+
"url": "https://github.com/lambda-kata/cdk.git"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"constructs": "^10.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@aws-sdk/client-lambda": "^3.500.0",
|
|
56
57
|
"@aws-sdk/client-sts": "^3.500.0",
|
|
57
58
|
"dotenv": "^17.2.3",
|
|
58
59
|
"reflect-metadata": "^0.2.2"
|