@lambda-kata/cdk 0.1.3-rc.9 → 0.1.3-rc.90

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.
@@ -15,7 +15,8 @@
15
15
  * @module aws-layer-manager
16
16
  */
17
17
  import { LambdaClientConfig } from '@aws-sdk/client-lambda';
18
- import { LayerManager, LayerInfo, LayerSearchOptions, LayerRequirements, LayerCreationOptions, Logger } from './nodejs-layer-manager';
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
  *
@@ -320,17 +430,42 @@ export declare class AWSLayerManager implements LayerManager {
320
430
  /**
321
431
  * Optimizes Node.js binary to reduce size while preserving functionality.
322
432
  *
323
- * Applies size optimization techniques:
324
- * 1. Strip debug symbols using 'strip' command (reduces size by 30-50%)
325
- * 2. Verify binary functionality after optimization
326
- * 3. Fallback to original binary if optimization fails
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
327
439
  *
328
440
  * @param originalBinaryPath - Path to the original Node.js binary
329
441
  * @param tempDir - Temporary directory for optimization work
330
442
  * @returns Promise resolving to path of optimized binary
331
- * @throws Error if optimization fails and fallback is not viable
443
+ * @throws Error if optimization fails and original exceeds 250MB limit
332
444
  */
333
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;
334
469
  /**
335
470
  * Verifies that a Node.js binary is functional after optimization.
336
471
  *
@@ -341,14 +476,26 @@ export declare class AWSLayerManager implements LayerManager {
341
476
  * @throws Error if verification fails
342
477
  */
343
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;
344
490
  /**
345
491
  * Creates the proper Lambda Layer directory structure.
346
492
  *
347
493
  * Lambda Layers for Node.js binary should use minimal structure:
348
- * - bin/node (not /opt/nodejs/bin/node)
494
+ * - bin/node (uncompressed binary)
495
+ * - bin/node.gz (compressed binary with decompression script)
349
496
  *
350
497
  * @param tempDir - Base temporary directory
351
- * @param nodeBinaryPath - Path to the Node.js binary
498
+ * @param nodeBinaryPath - Path to the Node.js binary (may be compressed)
352
499
  * @returns Promise resolving to the layer directory path
353
500
  * @throws Error if directory creation fails
354
501
  */
@@ -374,7 +521,10 @@ export declare class AWSLayerManager implements LayerManager {
374
521
  */
375
522
  private calculateDirectorySize;
376
523
  /**
377
- * 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.
378
528
  *
379
529
  * @param layerDir - Directory containing the layer contents
380
530
  * @param zipFilePath - Target ZIP file path
@@ -447,6 +597,9 @@ export declare class AWSLayerManager implements LayerManager {
447
597
  /**
448
598
  * Executes a system command with timeout and error handling.
449
599
  *
600
+ * Enhanced with EPIPE error handling to prevent broken pipe errors
601
+ * when child process terminates unexpectedly.
602
+ *
450
603
  * @param command - Command to execute
451
604
  * @param args - Command arguments
452
605
  * @param options - Execution options including working directory
@@ -1,4 +1,4 @@
1
- import { RuntimeDetector, NodeVersionInfo, Logger } from './nodejs-layer-manager';
1
+ import { Logger, NodeVersionInfo, RuntimeDetector } from './nodejs-layer-manager';
2
2
  /**
3
3
  * Configuration options for DockerRuntimeDetector.
4
4
  */
@@ -21,9 +21,12 @@ 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 { kata, kataWithAccountId, applyTransformation, handleUnlicensed, isKataTransformed, getKataPromise, KataWrapperOptions, KataResult, } from './kata-wrapper';
24
+ export { resolveAccountIdSync, resolveAccountIdSyncWithSource, resolveRegionSync, SyncAccountResolutionError, SyncAccountResolutionResult, SyncAccountResolverOptions, } from './sync-account-resolver';
25
+ export { kata, kataWithAccountId, applyTransformation, handleUnlicensed, isKataTransformed, getKataPromise, extractBundlePathFromHandler, KataWrapperOptions, KataResult, } from './kata-wrapper';
26
+ export { SnapStartActivator, SnapStartActivatorProps, } from './snapstart-construct';
27
+ export { activateSnapStart, SnapStartActivationResult, SnapStartActivatorConfig, } from './snapstart-activator';
25
28
  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';
29
+ export { EnsureNodeRuntimeLayerOptions, EnsureNodeRuntimeLayerResult, NodeVersionInfo, LayerInfo, LayerSearchOptions, LayerRequirements, LayerCreationOptions, Logger, RuntimeDetector, LayerManager, ErrorCodes, NodeRuntimeLayerError, VersionCacheEntry, LayerMetadata, NodejsLayerDeploymentOptions, NodejsLayerDeploymentResult, MultiArchitectureDeploymentResult, } from './nodejs-layer-manager';
27
30
  export { DockerRuntimeDetector, DockerRuntimeDetectorOptions, } from './docker-runtime-detector';
28
31
  export { AWSLayerManager, AWSLayerManagerOptions, } from './aws-layer-manager';
29
32
  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,37 @@ 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>;
139
+ /**
140
+ * Lambda task root directory where function code is deployed.
141
+ * This is the standard AWS Lambda directory for function code.
142
+ *
143
+ * @deprecated C-lang Lambda Kata makes its own decision for either absolute or relative path
144
+ */
145
+ /**
146
+ * Extracts the bundle path from a Lambda handler string.
147
+ *
148
+ * The handler format is "<module>.<function>" or "<path/module>.<function>".
149
+ * This function extracts the module path, appends ".js" extension,
150
+ * and prepends the Lambda task root directory (/var/task).
151
+ *
152
+ * @param handler - The Lambda handler string (e.g., "index.handler", "src/app.myHandler")
153
+ * @returns The absolute bundle path in Lambda environment (e.g., "/var/task/index.js")
154
+ *
155
+ * @example
156
+ * extractBundlePathFromHandler("index.handler") // => "/var/task/index.js"
157
+ * extractBundlePathFromHandler("src/app.myHandler") // => "/var/task/src/app.js"
158
+ * extractBundlePathFromHandler("dist/handlers/api.handler") // => "/var/task/dist/handlers/api.js"
159
+ *
160
+ * @internal
161
+ */
162
+ export declare function extractBundlePathFromHandler(handler: string): string;
119
163
  /**
120
164
  * Gets the original runtime from a Lambda function before transformation.
121
165
  *
@@ -143,32 +187,6 @@ export declare function isNodejsRuntime(lambda: NodejsFunction | LambdaFunction)
143
187
  * @internal
144
188
  */
145
189
  export declare function getLambdaArchitecture(lambda: NodejsFunction | LambdaFunction): 'x86_64' | 'arm64';
146
- /**
147
- * Applies the Lambda Kata transformation to a Lambda function.
148
- *
149
- * This function modifies the Lambda construct in-place to:
150
- * 1. Create and attach a config layer with the original handler path
151
- * 2. Change the runtime to Python 3.12
152
- * 3. Set the handler to the Lambda Kata handler
153
- * 4. Attach the customer-specific Lambda Layer
154
- * 5. Add additional environment variables for the Lambda Kata runtime
155
- *
156
- * @param lambda - The Lambda function to transform
157
- * @param config - The transformation configuration
158
- *
159
- * @remarks
160
- * Validates: Requirements 2.2, 2.3, 2.4, 3.3, 3.4, 4.1, 4.2, 5.4
161
- * - 2.2: THE kata_Wrapper SHALL change the Lambda runtime from Node.js to Python 3.12
162
- * - 2.3: THE kata_Wrapper SHALL set the Lambda handler to `lambdakata.optimized_handler.lambda_handler`
163
- * - 2.4: THE kata_Wrapper SHALL attach the customer-specific Lambda_Layer ARN to the Lambda
164
- * - 3.3: THE kata_Wrapper SHALL attach the Config_Layer to the transformed Lambda
165
- * - 3.4: THE kata_Wrapper SHALL NOT set the `JS_HANDLER_PATH` environment variable
166
- * - 4.1: THE kata_Wrapper SHALL NOT add the `JS_HANDLER_PATH` environment variable to transformed Lambdas
167
- * - 4.2: WHEN `bundlePath` is specified, THE kata_Wrapper SHALL write it to the Config_Layer JSON as `bundle_path`
168
- * - 5.4: THE compiled middleware SHALL be included in the Config_Layer at `/opt/.kata/middleware.js`
169
- *
170
- * @internal
171
- */
172
190
  export declare function applyTransformation(lambda: NodejsFunction | LambdaFunction, config: TransformationConfig): void;
173
191
  /**
174
192
  * Handles the case when an account is not licensed.
@@ -68,6 +68,10 @@ export declare class MockLicensingService implements LicensingService {
68
68
  * Custom error message when simulating service errors.
69
69
  */
70
70
  private serviceErrorMessage;
71
+ /**
72
+ * Flag to simulate entitled response without layerArn (service issue).
73
+ */
74
+ private simulateEntitledWithoutLayerArn;
71
75
  /**
72
76
  * Sets an account as entitled with a specific Layer ARN.
73
77
  *
@@ -147,6 +151,20 @@ export declare class MockLicensingService implements LicensingService {
147
151
  * ```
148
152
  */
149
153
  setSimulateServiceError(simulate: boolean, errorMessage?: string): void;
154
+ /**
155
+ * Configures the mock to simulate entitled response without layerArn.
156
+ * This simulates a licensing service issue where the account is entitled
157
+ * but the service fails to return the layer ARN.
158
+ *
159
+ * @param simulate - Whether to simulate entitled without layerArn
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * // Simulate service returning entitled: true but no layerArn
164
+ * mockService.setSimulateEntitledWithoutLayerArn(true);
165
+ * ```
166
+ */
167
+ setSimulateEntitledWithoutLayerArn(simulate: boolean): void;
150
168
  /**
151
169
  * Check if an AWS account is entitled to use Lambda Kata.
152
170
  *
@@ -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
+ }