File tree Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Expand file tree Collapse file tree 2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -259,17 +259,17 @@ class AwsDeployFunction {
259259 delete params . Timeout ;
260260 }
261261
262- if ( functionObj . layers && ! functionObj . layers . some ( _ . isObject ) ) {
263- params . Layers = functionObj . layers ;
264- }
265-
266262 const isConsoleEnabled =
267263 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- }
272264
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 ( ) ) ;
273273 if (
274274 params . Layers &&
275275 remoteFunctionConfiguration . Layers &&
Original file line number Diff line number Diff line change @@ -405,7 +405,26 @@ describe('test/unit/lib/classes/console.test.js', () => {
405405 awsRequestStubMap : {
406406 ...awsRequestStubMap ,
407407 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+ } ,
409428 listLayerVersions ( ) {
410429 if ( isFirstLayerVersionsQuery ) {
411430 isFirstLayerVersionsQuery = false ;
@@ -433,6 +452,11 @@ describe('test/unit/lib/classes/console.test.js', () => {
433452 . be . true ;
434453 } ) ;
435454
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+
436460 it ( 'should activate otel ingestion token' , ( ) => {
437461 otelIngenstionRequests . includes ( 'activate-token' ) ;
438462 } ) ;
You can’t perform that action at this time.
0 commit comments