@@ -174,8 +174,22 @@ class ConfigureLambdaLogs {
174174 // Function might be in a nested stack
175175 for ( const nestedStack of nestedStacks ) {
176176 const nestedStackName = nestedStack . logicalId ;
177- // Check if we have a reference to a function with this name in the nested stack
178- if ( nestedStackName . includes ( functionName . replace ( / _ / g, 'Underscore' ) ) ) {
177+ // Get the normalized function name for different possible formats
178+ const normalizedFuncName = functionName . replace ( / _ / g, 'Underscore' ) ;
179+ const stageName = this . serverless . service . provider . stage ;
180+ const serviceName = this . serverless . service . service ;
181+
182+ // Create variations of the function name to check against
183+ const nameVariations = [
184+ normalizedFuncName , // Base name
185+ `${ normalizedFuncName } ${ stageName } ` , // With stage
186+ `${ normalizedFuncName } Dash${ stageName } ` , // With dash and stage
187+ `${ serviceName } ${ normalizedFuncName } ` , // With service name
188+ `${ serviceName } Dash${ stageName } Dash${ normalizedFuncName } ` // Full format
189+ ] ;
190+
191+ // Check if any name variation is included in the nested stack name
192+ if ( nameVariations . some ( name => nestedStackName . includes ( name ) ) ) {
179193 this . serverless . cli . log ( `Found potential nested stack for function ${ functionName } : ${ nestedStackName } ` ) ;
180194
181195 // Create a reference to the resource in the nested stack
@@ -285,6 +299,11 @@ class ConfigureLambdaLogs {
285299 // Store the configuration to use in the updateLoggingPostDeploy phase
286300 if ( ! this . _nestedStackConfigs ) this . _nestedStackConfigs = { } ;
287301 this . _nestedStackConfigs [ functionName ] = loggingConfig ;
302+
303+ // Debug log for nested stack detection
304+ this . serverless . cli . log ( `Configuration stored for post-deployment update: ${ JSON . stringify ( loggingConfig ) } ` ) ;
305+ this . serverless . cli . log ( `Function name will resolve to: ${ this . getFunctionName ( functionName ) } ` ) ;
306+ this . serverless . cli . log ( `Function is in nested stack: ${ resource . _nestedIn } ` ) ;
288307 continue ;
289308 }
290309
0 commit comments