diff --git a/src/ServerlessSpy.ts b/src/ServerlessSpy.ts index 3085635..4d1f682 100644 --- a/src/ServerlessSpy.ts +++ b/src/ServerlessSpy.ts @@ -414,9 +414,6 @@ export class ServerlessSpy extends Construct { const layerKey = (r: lambda.Runtime, a: lambda.Architecture) => `${r.toString()}_${a.name.toString()}`; - console.log('RUNTIME: ', runtime); - console.log('ARCHITECTURE: ', architecture); - let layer = this.layerMap[layerKey(runtime, architecture)]; let spyWrapperPath = '/opt/spy-wrapper'; @@ -430,20 +427,26 @@ export class ServerlessSpy extends Construct { spyWrapperPath = '/opt/python/spy-wrapper'; layer = layer || - new PythonLayerVersion(this, 'PythonExtension', { - compatibleRuntimes: [runtime], - compatibleArchitectures: [architecture], - entry: location, - bundling: { - bundlingFileAccess: BundlingFileAccess.VOLUME_COPY, - // command: [ - // `cp ${path.join( - // location.substring(0, location.lastIndexOf(path.sep)), - // 'spy-wrapper/spy-wrapper' - // )} /asset-output/python`, - // ], - }, - }); + new PythonLayerVersion( + this, + `PythonExtension${runtime.name + .replace('python', '') + .replace('.', '_')}`, + { + compatibleRuntimes: [runtime], + compatibleArchitectures: [architecture], + entry: location, + bundling: { + bundlingFileAccess: BundlingFileAccess.VOLUME_COPY, + // command: [ + // `cp ${path.join( + // location.substring(0, location.lastIndexOf(path.sep)), + // 'spy-wrapper/spy-wrapper' + // )} /asset-output/python`, + // ], + }, + } + ); break; case lambda.Runtime.NODEJS_12_X.name: case lambda.Runtime.NODEJS_14_X.name: diff --git a/test/cdk/src/pythonLambdaStack.ts b/test/cdk/src/pythonLambdaStack.ts index 84d6de0..746eb9b 100644 --- a/test/cdk/src/pythonLambdaStack.ts +++ b/test/cdk/src/pythonLambdaStack.ts @@ -23,7 +23,7 @@ export class PythonLambdaStack extends Stack { const func3 = new lambda.Function(this, 'MyLambdaThatFails', { memorySize: 512, timeout: Duration.seconds(5), - runtime: lambda.Runtime.PYTHON_3_9, + runtime: lambda.Runtime.PYTHON_3_11, // use a different version handler: 'lambdaFail.handler', architecture: Architecture.X86_64, code: lambda.Code.fromAsset(path.join(__dirname, '../functions/python/')),