Fazi
12/15/2021, 6:55 PM/**
* 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: [
functionSecurityGroup
],
logRetention: logs.RetentionDays.ONE_DAY,
layers: [layer], // This line is what seems to be causing the issue
});
However, I get the following error message:
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:
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
app.setDefaultFunctionProps({
runtime: "python3.8",
});
const stack = new MyStack(app, "stack");
cdk.Tags.of(stack).add("CfStackName", app.name);
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?thdxr
12/15/2021, 7:12 PMthdxr
12/15/2021, 7:12 PMthdxr
12/15/2021, 7:13 PM!app.local
Fazi
12/15/2021, 7:19 PM