File tree 2 files changed +33
-9
lines changed
2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -259,17 +259,17 @@ class AwsDeployFunction {
259
259
delete params . Timeout ;
260
260
}
261
261
262
- if ( functionObj . layers && ! functionObj . layers . some ( _ . isObject ) ) {
263
- params . Layers = functionObj . layers ;
264
- }
265
-
266
262
const isConsoleEnabled =
267
263
this . console . isEnabled && this . console . isFunctionSupported ( functionObj ) ;
268
- if ( isConsoleEnabled ) {
269
- if ( ! params . Layers ) params . Layers = [ ] ;
270
- params . Layers . push ( await this . console . ensureLayerVersion ( ) ) ;
271
- }
272
264
265
+ if ( functionObj . layers && ! functionObj . layers . some ( _ . isObject ) ) {
266
+ params . Layers = functionObj . layers ;
267
+ } else if ( isConsoleEnabled ) {
268
+ params . Layers = ( remoteFunctionConfiguration . Layers || [ ] )
269
+ . map ( ( layer ) => layer . Arn )
270
+ . filter ( ( layerArn ) => ! layerArn . includes ( 'layer:sls-console-otel-extension-' ) ) ;
271
+ }
272
+ if ( isConsoleEnabled ) params . Layers . push ( await this . console . ensureLayerVersion ( ) ) ;
273
273
if (
274
274
params . Layers &&
275
275
remoteFunctionConfiguration . Layers &&
Original file line number Diff line number Diff line change @@ -405,7 +405,26 @@ describe('test/unit/lib/classes/console.test.js', () => {
405
405
awsRequestStubMap : {
406
406
...awsRequestStubMap ,
407
407
Lambda : {
408
- getFunction : { Configuration : { State : 'Active' , LastUpdateStatus : 'Successful' } } ,
408
+ getFunction : {
409
+ Configuration : {
410
+ State : 'Active' ,
411
+ LastUpdateStatus : 'Successful' ,
412
+ Layers : [
413
+ {
414
+ Arn : 'arn:aws:lambda:us-east-1:999999999999:layer:sls-console-otel-extension-0-3-6:1' ,
415
+ CodeSize : 186038 ,
416
+ SigningProfileVersionArn : null ,
417
+ SigningJobArn : null ,
418
+ } ,
419
+ {
420
+ Arn : 'other-layer' ,
421
+ CodeSize : 186038 ,
422
+ SigningProfileVersionArn : null ,
423
+ SigningJobArn : null ,
424
+ } ,
425
+ ] ,
426
+ } ,
427
+ } ,
409
428
listLayerVersions ( ) {
410
429
if ( isFirstLayerVersionsQuery ) {
411
430
isFirstLayerVersionsQuery = false ;
@@ -433,6 +452,11 @@ describe('test/unit/lib/classes/console.test.js', () => {
433
452
. be . true ;
434
453
} ) ;
435
454
455
+ it ( 'should keep already attached lambda layers' , async ( ) => {
456
+ const layers = updateFunctionStub . args [ 0 ] [ 0 ] . Layers ;
457
+ expect ( layers . sort ( ) ) . to . deep . equal ( [ 'other-layer' , 'extension-arn' ] . sort ( ) ) ;
458
+ } ) ;
459
+
436
460
it ( 'should activate otel ingestion token' , ( ) => {
437
461
otelIngenstionRequests . includes ( 'activate-token' ) ;
438
462
} ) ;
You can’t perform that action at this time.
0 commit comments