# help


12/15/2021, 6:55 PM
Hi all, I am trying to make use of AWS lambda layers. I have defined in my stack definition the following:
Copy code
     * Lambda function layers
    const layer: any = new lambda.LayerVersion(this, 'integration-lambda-layers-forecast-layer', {
      code: lambda.Code.fromAsset(path.join(__dirname, '..', '..', 'lambda_layers')),
      compatibleRuntimes: [lambda.Runtime.PYTHON_3_8]

     * Lambda Functions
    const createDBTables = new Function(this, 'CreateDBTables', {
      runtime: "python3.8",
      srcPath: "src",
      handler: 'create_db_tables.handler',
      timeout: 300,
      environment: env,
      permissions: ['ssm', 'rds'],
      description: "do something with rds.",
      vpc: existingVpc,
      securityGroups: [
      logRetention: logs.RetentionDays.ONE_DAY,
      layers: [layer],                                // This line is what seems to be causing the issue
However, I get the following error message:
Copy code
Error: This lambda function uses a runtime that is incompatible with this layer (nodejs12.x is not in [python3.8])
In my index.ts file I have:
Copy code
import * as cdk from "@aws-cdk/core";

import MyStack from "./MyStack";
import * as sst from "@serverless-stack/resources";

export default function main(app: <http://sst.App|sst.App>): void {
  // Set default runtime for all functions
    runtime: "python3.8",

  const stack = new MyStack(app, "stack");

  cdk.Tags.of(stack).add("Organisation", 'asas');
  cdk.Tags.of(stack).add("Department", 'asas');
  cdk.Tags.of(stack).add("Environment", app.stage);
Can someone please explain why it throws that error - is there some sort of configuration missing? Given I am running a python lambda function, and the lambda layer is also in python, why does it need a nodejs runtime too?


12/15/2021, 7:12 PM
In local development mode we deploy a fake nodejs runtime to AWS that forwards requests to you
Hence the error
Layers don't work for local development so you should conditionally add them if


12/15/2021, 7:19 PM
Ah got it thank you - yes was not sure why I need to add the nodejs to get it to work. Thanks @thdxr!