@lambda-kata/cdk 0.1.3-rc.4 → 0.1.3-rc.40
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 +70 -59
- package/out/tsc/src/aws-layer-manager.d.ts +191 -10
- package/out/tsc/src/docker-runtime-detector.d.ts +1 -1
- package/out/tsc/src/index.d.ts +2 -1
- package/out/tsc/src/kata-wrapper.d.ts +22 -2
- package/out/tsc/src/nodejs-layer-manager.d.ts +128 -0
- package/out/tsc/src/sync-account-resolver.d.ts +63 -0
- package/package.json +5 -3
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* @module aws-layer-manager
|
|
16
16
|
*/
|
|
17
17
|
import { LambdaClientConfig } from '@aws-sdk/client-lambda';
|
|
18
|
-
import {
|
|
18
|
+
import { S3ClientConfig } from '@aws-sdk/client-s3';
|
|
19
|
+
import { LayerCreationOptions, LayerInfo, LayerManager, LayerRequirements, LayerSearchOptions, Logger, MultiArchitectureDeploymentResult, NodejsLayerDeploymentOptions, NodejsLayerDeploymentResult } from './nodejs-layer-manager';
|
|
19
20
|
/**
|
|
20
21
|
* Configuration options for AWSLayerManager.
|
|
21
22
|
*/
|
|
@@ -25,6 +26,11 @@ export interface AWSLayerManagerOptions {
|
|
|
25
26
|
* If not provided, uses default AWS SDK configuration.
|
|
26
27
|
*/
|
|
27
28
|
awsSdkConfig?: LambdaClientConfig;
|
|
29
|
+
/**
|
|
30
|
+
* AWS SDK configuration for S3 client.
|
|
31
|
+
* If not provided, uses the same configuration as Lambda client.
|
|
32
|
+
*/
|
|
33
|
+
s3SdkConfig?: S3ClientConfig;
|
|
28
34
|
/**
|
|
29
35
|
* Logger for debugging and monitoring.
|
|
30
36
|
* If not provided, uses createDefaultLogger().
|
|
@@ -64,6 +70,12 @@ export interface AWSLayerManagerOptions {
|
|
|
64
70
|
* Default: 2
|
|
65
71
|
*/
|
|
66
72
|
circuitBreakerSuccessThreshold?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Enable S3 support for large layer uploads.
|
|
75
|
+
* If true, creates S3Client for handling layers >50MB.
|
|
76
|
+
* Default: true
|
|
77
|
+
*/
|
|
78
|
+
enableS3Support?: boolean;
|
|
67
79
|
}
|
|
68
80
|
/**
|
|
69
81
|
* AWS Lambda Layer Manager implementation using AWS SDK v3.
|
|
@@ -91,9 +103,10 @@ export interface AWSLayerManagerOptions {
|
|
|
91
103
|
* }
|
|
92
104
|
* });
|
|
93
105
|
* ```
|
|
94
|
-
|
|
106
|
+
*/
|
|
95
107
|
export declare class AWSLayerManager implements LayerManager {
|
|
96
108
|
private readonly lambdaClient;
|
|
109
|
+
private readonly s3Client;
|
|
97
110
|
private readonly logger;
|
|
98
111
|
private readonly maxLayerAge;
|
|
99
112
|
private readonly maxRetries;
|
|
@@ -170,6 +183,103 @@ export declare class AWSLayerManager implements LayerManager {
|
|
|
170
183
|
* @throws NodeRuntimeLayerError if creation fails
|
|
171
184
|
*/
|
|
172
185
|
private performLayerCreation;
|
|
186
|
+
/**
|
|
187
|
+
* Deploys a pre-built Node.js Lambda Layer from ZIP file.
|
|
188
|
+
*
|
|
189
|
+
* This method bypasses Docker binary extraction and deploys existing
|
|
190
|
+
* layer ZIP files directly to AWS Lambda. Handles large layers via S3
|
|
191
|
+
* temporary bucket upload with automatic cleanup.
|
|
192
|
+
*
|
|
193
|
+
* Process:
|
|
194
|
+
* 1. Validate input parameters and architecture
|
|
195
|
+
* 2. Search for existing layer ZIP files with fallback naming patterns
|
|
196
|
+
* 3. Read and validate layer ZIP file size
|
|
197
|
+
* 4. Deploy via direct upload (<50MB) or S3 upload (≥50MB)
|
|
198
|
+
* 5. Clean up temporary S3 resources if used
|
|
199
|
+
* 6. Return deployment result with layer ARN and metadata
|
|
200
|
+
*
|
|
201
|
+
* @param options - Deployment configuration
|
|
202
|
+
* @returns Promise resolving to deployment result
|
|
203
|
+
* @throws NodeRuntimeLayerError if deployment fails
|
|
204
|
+
*/
|
|
205
|
+
deployNodejsLayer(options: NodejsLayerDeploymentOptions): Promise<NodejsLayerDeploymentResult>;
|
|
206
|
+
/**
|
|
207
|
+
* Deploys Node.js layers for all supported architectures.
|
|
208
|
+
*
|
|
209
|
+
* Attempts to deploy layers for both arm64 and x86_64 architectures,
|
|
210
|
+
* continuing on individual failures to maximize successful deployments.
|
|
211
|
+
* This matches the behavior of the Python deployment script.
|
|
212
|
+
*
|
|
213
|
+
* @param options - Base deployment configuration (architecture will be overridden)
|
|
214
|
+
* @returns Promise resolving to multi-architecture deployment results
|
|
215
|
+
*/
|
|
216
|
+
deployAllArchitectures(options: Omit<NodejsLayerDeploymentOptions, 'architecture'>): Promise<MultiArchitectureDeploymentResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Generates a standard layer name for the given architecture.
|
|
219
|
+
*
|
|
220
|
+
* @param architecture - Target architecture
|
|
221
|
+
* @returns Standard layer name following the pattern: nodejs-18-{architecture}
|
|
222
|
+
*/
|
|
223
|
+
private generateLayerName;
|
|
224
|
+
/**
|
|
225
|
+
* Searches for layer ZIP files with fallback naming patterns.
|
|
226
|
+
*
|
|
227
|
+
* Implements the same search logic as the Python script with multiple
|
|
228
|
+
* naming conventions for maximum compatibility.
|
|
229
|
+
*
|
|
230
|
+
* @param architecture - Target architecture
|
|
231
|
+
* @param baseDirectory - Directory to search in
|
|
232
|
+
* @returns Promise resolving to ZIP file path or null if not found
|
|
233
|
+
*/
|
|
234
|
+
private findLayerZipFile;
|
|
235
|
+
/**
|
|
236
|
+
* Deploys a large layer (>50MB) via S3 temporary bucket.
|
|
237
|
+
*
|
|
238
|
+
* Creates a temporary S3 bucket, uploads the layer, publishes from S3,
|
|
239
|
+
* and cleans up the bucket. Implements the same logic as the Python script.
|
|
240
|
+
*
|
|
241
|
+
* @param layerName - Name of the layer
|
|
242
|
+
* @param layerContent - ZIP file content
|
|
243
|
+
* @param architecture - Target architecture
|
|
244
|
+
* @param region - AWS region
|
|
245
|
+
* @param description - Optional layer description
|
|
246
|
+
* @param zipFilePath - Original ZIP file path for metadata
|
|
247
|
+
* @returns Promise resolving to deployment result
|
|
248
|
+
*/
|
|
249
|
+
private deployLargeLayerViaS3;
|
|
250
|
+
/**
|
|
251
|
+
* Deploys a layer directly to Lambda (for layers <50MB).
|
|
252
|
+
*
|
|
253
|
+
* @param layerName - Name of the layer
|
|
254
|
+
* @param layerContent - ZIP file content
|
|
255
|
+
* @param architecture - Target architecture
|
|
256
|
+
* @param description - Optional layer description
|
|
257
|
+
* @param zipFilePath - Original ZIP file path for metadata
|
|
258
|
+
* @returns Promise resolving to deployment result
|
|
259
|
+
*/
|
|
260
|
+
private deployLayerDirect;
|
|
261
|
+
/**
|
|
262
|
+
* Creates an S3 bucket for temporary layer storage.
|
|
263
|
+
*
|
|
264
|
+
* @param bucketName - Name of the bucket to create
|
|
265
|
+
* @param region - AWS region
|
|
266
|
+
*/
|
|
267
|
+
private createS3Bucket;
|
|
268
|
+
/**
|
|
269
|
+
* Uploads layer content to S3.
|
|
270
|
+
*
|
|
271
|
+
* @param bucketName - S3 bucket name
|
|
272
|
+
* @param keyName - S3 object key
|
|
273
|
+
* @param layerContent - Layer ZIP content
|
|
274
|
+
*/
|
|
275
|
+
private uploadLayerToS3;
|
|
276
|
+
/**
|
|
277
|
+
* Cleans up S3 resources (bucket and objects).
|
|
278
|
+
*
|
|
279
|
+
* @param bucketName - S3 bucket name
|
|
280
|
+
* @param keyName - S3 object key
|
|
281
|
+
*/
|
|
282
|
+
private cleanupS3Resources;
|
|
173
283
|
/**
|
|
174
284
|
* Validates whether a layer meets the specified requirements.
|
|
175
285
|
*
|
|
@@ -299,11 +409,15 @@ export declare class AWSLayerManager implements LayerManager {
|
|
|
299
409
|
*/
|
|
300
410
|
private createTempDirectory;
|
|
301
411
|
/**
|
|
302
|
-
* Extracts Node.js binary from AWS Lambda Docker
|
|
412
|
+
* Extracts Node.js binary from AWS Lambda Docker image with resource tracking.
|
|
413
|
+
*
|
|
414
|
+
* Uses ONLY AWS Lambda Docker images to extract the Node.js binary from the
|
|
415
|
+
* official Lambda runtime environment. This ensures compatibility with the
|
|
416
|
+
* Lambda execution environment while extracting only the minimal binary needed.
|
|
303
417
|
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
418
|
+
* CRITICAL: Uses ONLY AWS Lambda Docker images as required by user specifications.
|
|
419
|
+
* Docker image format: public.ecr.aws/lambda/nodejs:{version}-{arch}
|
|
420
|
+
* Extracts ONLY: /var/lang/bin/node
|
|
307
421
|
*
|
|
308
422
|
* @param nodeVersion - The Node.js version (e.g., "20.10.0")
|
|
309
423
|
* @param architecture - The target architecture
|
|
@@ -313,14 +427,75 @@ export declare class AWSLayerManager implements LayerManager {
|
|
|
313
427
|
* @throws NodeRuntimeLayerError if extraction fails
|
|
314
428
|
*/
|
|
315
429
|
private extractNodeBinaryFromDockerWithTracking;
|
|
430
|
+
/**
|
|
431
|
+
* Optimizes Node.js binary to reduce size while preserving functionality.
|
|
432
|
+
*
|
|
433
|
+
* Multi-stage optimization approach:
|
|
434
|
+
* 1. Strip debug symbols using 'strip' command (30-50% reduction)
|
|
435
|
+
* 2. UPX compression if still >50MB (50-70% additional reduction)
|
|
436
|
+
* 3. System Node.js replacement if still >60MB
|
|
437
|
+
* 4. Verify binary functionality after each stage
|
|
438
|
+
* 5. Fallback to original if within 250MB limit
|
|
439
|
+
*
|
|
440
|
+
* @param originalBinaryPath - Path to the original Node.js binary
|
|
441
|
+
* @param tempDir - Temporary directory for optimization work
|
|
442
|
+
* @returns Promise resolving to path of optimized binary
|
|
443
|
+
* @throws Error if optimization fails and original exceeds 250MB limit
|
|
444
|
+
*/
|
|
445
|
+
private optimizeNodeBinary;
|
|
446
|
+
/**
|
|
447
|
+
* Attempts strip-based optimization with progressive aggressiveness.
|
|
448
|
+
*
|
|
449
|
+
* @param originalBinaryPath - Path to original binary
|
|
450
|
+
* @param tempDir - Working directory
|
|
451
|
+
* @returns Path to stripped binary or original if stripping fails
|
|
452
|
+
*/
|
|
453
|
+
private tryStripOptimization;
|
|
454
|
+
/**
|
|
455
|
+
* Attempts UPX compression optimization.
|
|
456
|
+
*
|
|
457
|
+
* @param binaryPath - Path to binary to compress
|
|
458
|
+
* @param tempDir - Working directory
|
|
459
|
+
* @returns Path to compressed binary or null if UPX unavailable/fails
|
|
460
|
+
*/
|
|
461
|
+
private tryUPXOptimization;
|
|
462
|
+
/**
|
|
463
|
+
* Attempts to use system Node.js binary as replacement.
|
|
464
|
+
*
|
|
465
|
+
* @param tempDir - Working directory
|
|
466
|
+
* @returns Path to system Node.js copy or null if unavailable/unsuitable
|
|
467
|
+
*/
|
|
468
|
+
private trySystemNodeReplacement;
|
|
469
|
+
/**
|
|
470
|
+
* Verifies that a Node.js binary is functional after optimization.
|
|
471
|
+
*
|
|
472
|
+
* Runs basic Node.js commands to ensure the binary works correctly.
|
|
473
|
+
* This prevents shipping broken binaries after optimization.
|
|
474
|
+
*
|
|
475
|
+
* @param binaryPath - Path to the Node.js binary to verify
|
|
476
|
+
* @throws Error if verification fails
|
|
477
|
+
*/
|
|
478
|
+
private verifyNodeBinary;
|
|
479
|
+
/**
|
|
480
|
+
* Verifies Node.js binary with graceful fallback for spawn errors.
|
|
481
|
+
*
|
|
482
|
+
* This method attempts full verification but falls back to basic checks
|
|
483
|
+
* if spawn fails (e.g., error -8). This prevents blocking deployment for
|
|
484
|
+
* binaries that are valid but fail verification due to system issues.
|
|
485
|
+
*
|
|
486
|
+
* @param binaryPath - Path to the Node.js binary to verify
|
|
487
|
+
* @returns Promise resolving to verification result with success flag and optional error
|
|
488
|
+
*/
|
|
489
|
+
private verifyNodeBinaryWithFallback;
|
|
316
490
|
/**
|
|
317
491
|
* Creates the proper Lambda Layer directory structure.
|
|
318
492
|
*
|
|
319
|
-
* Lambda Layers
|
|
320
|
-
* -
|
|
493
|
+
* Lambda Layers for Node.js binary should use minimal structure:
|
|
494
|
+
* - bin/node (uncompressed binary)
|
|
495
|
+
* - bin/node.gz (compressed binary with decompression script)
|
|
321
496
|
*
|
|
322
497
|
* @param tempDir - Base temporary directory
|
|
323
|
-
* @param nodeBinaryPath - Path to the Node.js binary
|
|
498
|
+
* @param nodeBinaryPath - Path to the Node.js binary (may be compressed)
|
|
324
499
|
* @returns Promise resolving to the layer directory path
|
|
325
500
|
* @throws Error if directory creation fails
|
|
326
501
|
*/
|
|
@@ -346,7 +521,10 @@ export declare class AWSLayerManager implements LayerManager {
|
|
|
346
521
|
*/
|
|
347
522
|
private calculateDirectorySize;
|
|
348
523
|
/**
|
|
349
|
-
* Fallback ZIP creation using system zip command.
|
|
524
|
+
* Fallback ZIP creation using system zip command with streaming.
|
|
525
|
+
*
|
|
526
|
+
* This method uses the system 'zip' command which handles large files
|
|
527
|
+
* efficiently without loading them into memory.
|
|
350
528
|
*
|
|
351
529
|
* @param layerDir - Directory containing the layer contents
|
|
352
530
|
* @param zipFilePath - Target ZIP file path
|
|
@@ -419,6 +597,9 @@ export declare class AWSLayerManager implements LayerManager {
|
|
|
419
597
|
/**
|
|
420
598
|
* Executes a system command with timeout and error handling.
|
|
421
599
|
*
|
|
600
|
+
* Enhanced with EPIPE error handling to prevent broken pipe errors
|
|
601
|
+
* when child process terminates unexpectedly.
|
|
602
|
+
*
|
|
422
603
|
* @param command - Command to execute
|
|
423
604
|
* @param args - Command arguments
|
|
424
605
|
* @param options - Execution options including working directory
|
package/out/tsc/src/index.d.ts
CHANGED
|
@@ -21,9 +21,10 @@ export { KataProps, LicensingResponse, TransformationConfig } from './types';
|
|
|
21
21
|
export { LicensingService, HttpLicensingService, createLicensingService, isValidAccountId, } from './licensing';
|
|
22
22
|
export { MockLicensingService, createMockLicensingService, } from './mock-licensing';
|
|
23
23
|
export { resolveAccountId, resolveAccountIdWithSource, isValidAccountIdFormat, AccountResolutionError, AccountResolutionResult, AccountResolverOptions, } from './account-resolver';
|
|
24
|
+
export { resolveAccountIdSync, resolveAccountIdSyncWithSource, resolveRegionSync, SyncAccountResolutionError, SyncAccountResolutionResult, SyncAccountResolverOptions, } from './sync-account-resolver';
|
|
24
25
|
export { kata, kataWithAccountId, applyTransformation, handleUnlicensed, isKataTransformed, getKataPromise, KataWrapperOptions, KataResult, } from './kata-wrapper';
|
|
25
26
|
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 { EnsureNodeRuntimeLayerOptions, EnsureNodeRuntimeLayerResult, NodeVersionInfo, LayerInfo, LayerSearchOptions, LayerRequirements, LayerCreationOptions, Logger, RuntimeDetector, LayerManager, ErrorCodes, NodeRuntimeLayerError, VersionCacheEntry, LayerMetadata, NodejsLayerDeploymentOptions, NodejsLayerDeploymentResult, MultiArchitectureDeploymentResult, } from './nodejs-layer-manager';
|
|
27
28
|
export { DockerRuntimeDetector, DockerRuntimeDetectorOptions, } from './docker-runtime-detector';
|
|
28
29
|
export { AWSLayerManager, AWSLayerManagerOptions, } from './aws-layer-manager';
|
|
29
30
|
export { NoOpLogger, ConsoleLogger, createDefaultLogger, OperationTimer, } from './logger';
|
|
@@ -2,6 +2,7 @@ import { Function as LambdaFunction } from 'aws-cdk-lib/aws-lambda';
|
|
|
2
2
|
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
3
3
|
import { KataProps, LicensingResponse, TransformationConfig } from './types';
|
|
4
4
|
import { LicensingService } from './licensing';
|
|
5
|
+
import { LicensingService as NativeLicensingServiceInterface } from '@lambda-kata/licensing';
|
|
5
6
|
/**
|
|
6
7
|
* Options for the kata wrapper, extending KataProps with internal options.
|
|
7
8
|
*/
|
|
@@ -12,6 +13,12 @@ export interface KataWrapperOptions extends KataProps {
|
|
|
12
13
|
* @internal
|
|
13
14
|
*/
|
|
14
15
|
licensingService?: LicensingService;
|
|
16
|
+
/**
|
|
17
|
+
* Optional: Custom synchronous licensing service for testing.
|
|
18
|
+
* Must implement checkEntitlementSync(accountId: string): LicensingResponse
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
syncLicensingService?: NativeLicensingServiceInterface;
|
|
15
22
|
/**
|
|
16
23
|
* Custom bundle path.
|
|
17
24
|
* If not specified, uses the default /opt/js_runtime/bundle.js
|
|
@@ -47,6 +54,15 @@ export interface KataWrapperOptions extends KataProps {
|
|
|
47
54
|
handlerResolver?: (bundle: unknown, context: {
|
|
48
55
|
originalHandler: string;
|
|
49
56
|
}) => Function;
|
|
57
|
+
/**
|
|
58
|
+
* Skip Node.js runtime layer deployment.
|
|
59
|
+
* When true, only the core transformation is applied without deploying
|
|
60
|
+
* the Node.js runtime layer. Useful for faster synthesis when the layer
|
|
61
|
+
* is already deployed or not needed.
|
|
62
|
+
*
|
|
63
|
+
* Default: false
|
|
64
|
+
*/
|
|
65
|
+
skipNodejsLayer?: boolean;
|
|
50
66
|
}
|
|
51
67
|
/**
|
|
52
68
|
* Result of the kata transformation.
|
|
@@ -68,12 +84,15 @@ export interface KataResult {
|
|
|
68
84
|
/**
|
|
69
85
|
* Transforms a Node.js Lambda function to run via the Lambda Kata runtime.
|
|
70
86
|
*
|
|
71
|
-
* This function performs the following steps:
|
|
87
|
+
* This function performs the following steps SYNCHRONOUSLY:
|
|
72
88
|
* 1. Resolves the target AWS account ID
|
|
73
89
|
* 2. Calls the licensing service to validate entitlement
|
|
74
90
|
* 3. If entitled, applies transformations (runtime, handler, layer, env vars)
|
|
75
91
|
* 4. If not entitled, handles according to unlicensedBehavior option
|
|
76
92
|
*
|
|
93
|
+
* IMPORTANT: This function is SYNCHRONOUS to work correctly with CDK synthesis.
|
|
94
|
+
* All licensing checks and transformations are applied immediately before returning.
|
|
95
|
+
*
|
|
77
96
|
* @param lambda - The Node.js Lambda function to transform (NodejsFunction or Function)
|
|
78
97
|
* @param props - Optional configuration for the transformation
|
|
79
98
|
* @returns The same Lambda construct (modified if licensed)
|
|
@@ -110,12 +129,13 @@ export declare function kata<T extends NodejsFunction | LambdaFunction>(lambda:
|
|
|
110
129
|
*
|
|
111
130
|
* @param lambda - The Node.js Lambda function to transform
|
|
112
131
|
* @param accountId - The AWS account ID to use for licensing check
|
|
132
|
+
* @param region - The AWS region for deployment (from Stack.of(lambda).region)
|
|
113
133
|
* @param props - Optional configuration for the transformation
|
|
114
134
|
* @returns Promise resolving to the transformation result
|
|
115
135
|
*
|
|
116
136
|
* @internal
|
|
117
137
|
*/
|
|
118
|
-
export declare function kataWithAccountId<T extends NodejsFunction | LambdaFunction>(lambda: T, accountId: string, props?: KataWrapperOptions): Promise<KataResult>;
|
|
138
|
+
export declare function kataWithAccountId<T extends NodejsFunction | LambdaFunction>(lambda: T, accountId: string, region: string, props?: KataWrapperOptions): Promise<KataResult>;
|
|
119
139
|
/**
|
|
120
140
|
* Gets the original runtime from a Lambda function before transformation.
|
|
121
141
|
*
|
|
@@ -275,6 +275,27 @@ export interface LayerManager {
|
|
|
275
275
|
* @throws NodeRuntimeLayerError if creation fails
|
|
276
276
|
*/
|
|
277
277
|
createNodeLayer(options: LayerCreationOptions): Promise<LayerInfo>;
|
|
278
|
+
/**
|
|
279
|
+
* Deploys a pre-built Node.js Lambda Layer from ZIP file.
|
|
280
|
+
*
|
|
281
|
+
* This method bypasses Docker binary extraction and deploys existing
|
|
282
|
+
* layer ZIP files directly to AWS Lambda. Handles large layers via S3.
|
|
283
|
+
*
|
|
284
|
+
* @param options - Deployment configuration
|
|
285
|
+
* @returns Promise resolving to deployment result
|
|
286
|
+
* @throws NodeRuntimeLayerError if deployment fails
|
|
287
|
+
*/
|
|
288
|
+
deployNodejsLayer(options: NodejsLayerDeploymentOptions): Promise<NodejsLayerDeploymentResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Deploys Node.js layers for all supported architectures.
|
|
291
|
+
*
|
|
292
|
+
* Attempts to deploy layers for both arm64 and x86_64 architectures,
|
|
293
|
+
* continuing on individual failures to maximize successful deployments.
|
|
294
|
+
*
|
|
295
|
+
* @param options - Base deployment configuration (architecture will be overridden)
|
|
296
|
+
* @returns Promise resolving to multi-architecture deployment results
|
|
297
|
+
*/
|
|
298
|
+
deployAllArchitectures(options: Omit<NodejsLayerDeploymentOptions, 'architecture'>): Promise<MultiArchitectureDeploymentResult>;
|
|
278
299
|
/**
|
|
279
300
|
* Validates whether a layer meets the specified requirements.
|
|
280
301
|
*
|
|
@@ -417,3 +438,110 @@ export interface LayerMetadata {
|
|
|
417
438
|
*/
|
|
418
439
|
licenseInfo?: string;
|
|
419
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Configuration options for deploying pre-built Node.js Lambda Layers.
|
|
443
|
+
*
|
|
444
|
+
* Used to deploy existing layer ZIP files instead of creating layers from Docker images.
|
|
445
|
+
* This bypasses the binary extraction process that can fail with large Node.js binaries.
|
|
446
|
+
*/
|
|
447
|
+
export interface NodejsLayerDeploymentOptions {
|
|
448
|
+
/**
|
|
449
|
+
* The AWS region where the layer should be deployed.
|
|
450
|
+
*/
|
|
451
|
+
region: string;
|
|
452
|
+
/**
|
|
453
|
+
* Optional AWS profile name for authentication.
|
|
454
|
+
* If not provided, uses default AWS credentials.
|
|
455
|
+
*/
|
|
456
|
+
profile?: string;
|
|
457
|
+
/**
|
|
458
|
+
* The target architecture for deployment.
|
|
459
|
+
* If not specified, defaults to 'arm64'.
|
|
460
|
+
*/
|
|
461
|
+
architecture?: 'arm64' | 'x86_64';
|
|
462
|
+
/**
|
|
463
|
+
* Base directory to search for layer ZIP files.
|
|
464
|
+
* Defaults to current working directory.
|
|
465
|
+
*/
|
|
466
|
+
baseDirectory?: string;
|
|
467
|
+
/**
|
|
468
|
+
* Custom layer name override.
|
|
469
|
+
* If not provided, uses standard naming: nodejs-18-{architecture}
|
|
470
|
+
*/
|
|
471
|
+
layerName?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Custom layer description.
|
|
474
|
+
* If not provided, generates standard description.
|
|
475
|
+
*/
|
|
476
|
+
description?: string;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Result of Node.js layer deployment operation.
|
|
480
|
+
*
|
|
481
|
+
* Contains information about the deployed layer and deployment metadata.
|
|
482
|
+
*/
|
|
483
|
+
export interface NodejsLayerDeploymentResult {
|
|
484
|
+
/**
|
|
485
|
+
* The full ARN of the deployed layer version.
|
|
486
|
+
*/
|
|
487
|
+
layerVersionArn: string;
|
|
488
|
+
/**
|
|
489
|
+
* The base ARN of the layer (without version).
|
|
490
|
+
*/
|
|
491
|
+
layerArn: string;
|
|
492
|
+
/**
|
|
493
|
+
* The name of the deployed layer.
|
|
494
|
+
*/
|
|
495
|
+
layerName: string;
|
|
496
|
+
/**
|
|
497
|
+
* The version number of the deployed layer.
|
|
498
|
+
*/
|
|
499
|
+
version: number;
|
|
500
|
+
/**
|
|
501
|
+
* The architecture of the deployed layer.
|
|
502
|
+
*/
|
|
503
|
+
architecture: 'arm64' | 'x86_64';
|
|
504
|
+
/**
|
|
505
|
+
* The size of the deployed layer ZIP file in bytes.
|
|
506
|
+
*/
|
|
507
|
+
layerSize: number;
|
|
508
|
+
/**
|
|
509
|
+
* The path to the ZIP file that was deployed.
|
|
510
|
+
*/
|
|
511
|
+
zipFilePath: string;
|
|
512
|
+
/**
|
|
513
|
+
* Whether the layer was uploaded via S3 (true) or direct upload (false).
|
|
514
|
+
*/
|
|
515
|
+
uploadedViaS3: boolean;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Result of deploying layers for all architectures.
|
|
519
|
+
*
|
|
520
|
+
* Contains deployment results for each architecture attempted.
|
|
521
|
+
*/
|
|
522
|
+
export interface MultiArchitectureDeploymentResult {
|
|
523
|
+
/**
|
|
524
|
+
* Deployment results by architecture.
|
|
525
|
+
* Key is architecture name, value is result or null if deployment failed.
|
|
526
|
+
*/
|
|
527
|
+
results: Record<'arm64' | 'x86_64', NodejsLayerDeploymentResult | null>;
|
|
528
|
+
/**
|
|
529
|
+
* Overall success status.
|
|
530
|
+
* True if at least one architecture deployed successfully.
|
|
531
|
+
*/
|
|
532
|
+
success: boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Summary of successful deployments.
|
|
535
|
+
*/
|
|
536
|
+
successful: Array<{
|
|
537
|
+
architecture: 'arm64' | 'x86_64';
|
|
538
|
+
layerVersionArn: string;
|
|
539
|
+
}>;
|
|
540
|
+
/**
|
|
541
|
+
* Summary of failed deployments.
|
|
542
|
+
*/
|
|
543
|
+
failed: Array<{
|
|
544
|
+
architecture: 'arm64' | 'x86_64';
|
|
545
|
+
error: string;
|
|
546
|
+
}>;
|
|
547
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synchronous Account ID Resolution for Lambda Kata CDK Integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides synchronous account ID resolution for use during
|
|
5
|
+
* CDK synthesis, which requires synchronous operations.
|
|
6
|
+
*
|
|
7
|
+
* Resolution strategies (in order of precedence):
|
|
8
|
+
* 1. CDK context value (explicit configuration)
|
|
9
|
+
* 2. Stack account (if not a token/unresolved)
|
|
10
|
+
* 3. Environment variables (AWS_ACCOUNT_ID, CDK_DEFAULT_ACCOUNT)
|
|
11
|
+
* 4. STS GetCallerIdentity via execSync (fallback)
|
|
12
|
+
*
|
|
13
|
+
* @module sync-account-resolver
|
|
14
|
+
*/
|
|
15
|
+
import { Construct } from 'constructs';
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when account ID cannot be resolved through any strategy.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SyncAccountResolutionError extends Error {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of account ID resolution, including the source of the resolution.
|
|
24
|
+
*/
|
|
25
|
+
export interface SyncAccountResolutionResult {
|
|
26
|
+
accountId: string;
|
|
27
|
+
source: 'context' | 'stack' | 'env' | 'sts';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for synchronous account ID resolution.
|
|
31
|
+
*/
|
|
32
|
+
export interface SyncAccountResolverOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Whether to skip the STS fallback (useful for testing).
|
|
35
|
+
* Default: false
|
|
36
|
+
*/
|
|
37
|
+
skipStsFallback?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves the target AWS account ID synchronously.
|
|
41
|
+
*
|
|
42
|
+
* This function attempts to determine the AWS account ID using multiple
|
|
43
|
+
* strategies in order of precedence:
|
|
44
|
+
*
|
|
45
|
+
* 1. **CDK Context**: Checks for `aws:cdk:account` context value
|
|
46
|
+
* 2. **Stack Account**: Uses the Stack's account if it's not a token
|
|
47
|
+
* 3. **Environment Variables**: Checks AWS_ACCOUNT_ID, CDK_DEFAULT_ACCOUNT
|
|
48
|
+
* 4. **STS Fallback**: Calls AWS CLI sts get-caller-identity
|
|
49
|
+
*
|
|
50
|
+
* @param scope - The CDK construct scope to resolve the account for
|
|
51
|
+
* @param options - Optional configuration for resolution behavior
|
|
52
|
+
* @returns The AWS account ID (12-digit string)
|
|
53
|
+
* @throws SyncAccountResolutionError if account cannot be resolved
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveAccountIdSync(scope: Construct, options?: SyncAccountResolverOptions): string;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the target AWS account ID synchronously with source information.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveAccountIdSyncWithSource(scope: Construct, options?: SyncAccountResolverOptions): SyncAccountResolutionResult;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the deployment region synchronously.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveRegionSync(scope: Construct): string;
|
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.40",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"docs": "yarn run docs:md && yarn run docs:html",
|
|
19
19
|
"docs:md": "typedoc --options ./docs/docs.config/typedoc.md.json",
|
|
20
20
|
"docs:html": "typedoc --options ./docs/docs.config/typedoc.html.json",
|
|
21
|
-
"npm:publish": "npm publish --access public"
|
|
21
|
+
"npm:publish": "yarn run build && npm publish --access public"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"out/dist/**/*",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@aws-sdk/client-lambda": "^3.500.0",
|
|
57
|
+
"@aws-sdk/client-s3": "^3.500.0",
|
|
57
58
|
"@aws-sdk/client-sts": "^3.500.0",
|
|
59
|
+
"@lambda-kata/licensing": "^0.1.11",
|
|
58
60
|
"dotenv": "^17.2.3",
|
|
59
61
|
"reflect-metadata": "^0.2.2"
|
|
60
62
|
},
|
|
@@ -74,4 +76,4 @@
|
|
|
74
76
|
"tsc-alias": "^1.8.16",
|
|
75
77
|
"typescript": "^5.3.3"
|
|
76
78
|
}
|
|
77
|
-
}
|
|
79
|
+
}
|