diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a88fec4..71eb2f5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,9 @@ updates: # default location of `.github/workflows` directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "friday" + time: "18:00" #UTC commit-message: prefix: "Upgrade: [dependabot] - " @@ -19,7 +21,9 @@ updates: - package-ecosystem: "npm" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "friday" + time: "18:00" #UTC versioning-strategy: increase open-pull-requests-limit: 20 commit-message: @@ -31,7 +35,9 @@ updates: - package-ecosystem: "pip" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "friday" + time: "18:00" #UTC versioning-strategy: increase commit-message: - prefix: "Upgrade: [dependabot] - " \ No newline at end of file + prefix: "Upgrade: [dependabot] - " diff --git a/.tool-versions b/.tool-versions index 506f12c..6905ea0 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ -nodejs 22.20.0 +nodejs 24.11.1 python 3.12.7 poetry 1.8.3 shellcheck 0.10.0 diff --git a/packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts b/packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts index bd8d7dc..3c18084 100644 --- a/packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts +++ b/packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts @@ -45,7 +45,7 @@ export interface TypescriptLambdaFunctionProps { /** * A map of environment variables to set for the lambda function. */ - readonly environmentVariables: {[key: string]: string} + readonly environmentVariables: { [key: string]: string } /** * Optional additional IAM policies to attach to role the lambda executes as. */ @@ -77,15 +77,23 @@ export interface TypescriptLambdaFunctionProps { * @default 50 seconds */ readonly timeoutInSeconds?: number + + /** + * Optional runtime for the Lambda function. + * @default Runtime.NODEJS_24_X + */ + readonly runtime?: Runtime } const insightsLayerArn = "arn:aws:lambda:eu-west-2:580247275435:layer:LambdaInsightsExtension:60" const getDefaultLambdaOptions = ( packageBasePath: string, projectBaseDir: string, - timeoutInSeconds: number):NodejsFunctionProps => { + timeoutInSeconds: number, + runtime: Runtime +): NodejsFunctionProps => { return { - runtime: Runtime.NODEJS_22_X, + runtime: runtime, projectRoot: projectBaseDir, memorySize: 256, timeout: Duration.seconds(timeoutInSeconds), @@ -170,7 +178,7 @@ export class TypescriptLambdaFunction extends Construct { * @param id - The scoped construct ID. Must be unique amongst siblings in the same scope * @param props - Configuration properties for the Lambda function */ - public constructor(scope: Construct, id: string, props: TypescriptLambdaFunctionProps){ + public constructor(scope: Construct, id: string, props: TypescriptLambdaFunctionProps) { super(scope, id) // Destructure with defaults @@ -186,7 +194,8 @@ export class TypescriptLambdaFunction extends Construct { commitId, layers = [], // Default to empty array projectBaseDir, - timeoutInSeconds = 50 + timeoutInSeconds = 50, + runtime = Runtime.NODEJS_24_X } = props // Imports @@ -266,7 +275,7 @@ export class TypescriptLambdaFunction extends Construct { }) const lambdaFunction = new NodejsFunction(this, functionName, { - ...getDefaultLambdaOptions(packageBasePath, projectBaseDir, timeoutInSeconds), + ...getDefaultLambdaOptions(packageBasePath, projectBaseDir, timeoutInSeconds, runtime), functionName: `${functionName}`, entry: join(projectBaseDir, packageBasePath, entryPoint), role, @@ -278,7 +287,7 @@ export class TypescriptLambdaFunction extends Construct { COMMIT_ID: commitId }, logGroup, - layers:[ + layers: [ insightsLambdaLayer, ...layers ] diff --git a/packages/cdkConstructs/tests/functionConstruct.test.ts b/packages/cdkConstructs/tests/functionConstruct.test.ts index bb2803f..36dfe65 100644 --- a/packages/cdkConstructs/tests/functionConstruct.test.ts +++ b/packages/cdkConstructs/tests/functionConstruct.test.ts @@ -1,7 +1,7 @@ import {App, assertions, Stack} from "aws-cdk-lib" import {ManagedPolicy, PolicyStatement, Role} from "aws-cdk-lib/aws-iam" import {LogGroup} from "aws-cdk-lib/aws-logs" -import {Function, LayerVersion} from "aws-cdk-lib/aws-lambda" +import {Function, LayerVersion, Runtime} from "aws-cdk-lib/aws-lambda" import {Template, Match} from "aws-cdk-lib/assertions" import { describe, @@ -114,7 +114,7 @@ describe("functionConstruct works correctly", () => { test("it has the correct lambda", () => { template.hasResourceProperties("AWS::Lambda::Function", { Handler: "index.handler", - Runtime: "nodejs22.x", + Runtime: "nodejs24.x", FunctionName: "testLambda", MemorySize: 256, Architectures: ["x86_64"], @@ -166,7 +166,7 @@ describe("functionConstruct works correctly with environment variables", () => { test("environment variables are added correctly", () => { template.hasResourceProperties("AWS::Lambda::Function", { - Runtime: "nodejs22.x", + Runtime: "nodejs24.x", FunctionName: "testLambda", Environment: {Variables: {foo: "bar"}} }) @@ -249,7 +249,7 @@ describe("functionConstruct works correctly with additional layers", () => { test("it has the correct layers added", () => { template.hasResourceProperties("AWS::Lambda::Function", { Handler: "index.handler", - Runtime: "nodejs22.x", + Runtime: "nodejs24.x", FunctionName: "testLambda", MemorySize: 256, Architectures: ["x86_64"], @@ -289,7 +289,7 @@ describe("functionConstruct works correctly with custom timeout", () => { test("it has the correct timeout", () => { template.hasResourceProperties("AWS::Lambda::Function", { Handler: "index.handler", - Runtime: "nodejs22.x", + Runtime: "nodejs24.x", FunctionName: "testLambda", MemorySize: 256, Architectures: ["x86_64"], @@ -297,3 +297,34 @@ describe("functionConstruct works correctly with custom timeout", () => { }) }) }) + +describe("functionConstruct works correctly with different runtime", () => { + let stack: Stack + let app: App + let template: assertions.Template + beforeAll(() => { + app = new App() + stack = new Stack(app, "lambdaConstructStack") + new TypescriptLambdaFunction(stack, "dummyFunction", { + functionName: "testLambda", + additionalPolicies: [], + packageBasePath: "packages/cdkConstructs", + entryPoint: "tests/src/dummyLambda.ts", + environmentVariables: {}, + logRetentionInDays: 30, + logLevel: "DEBUG", + version: "1.0.0", + commitId: "abcd1234", + projectBaseDir: resolve(__dirname, "../../.."), + runtime: Runtime.NODEJS_22_X + }) + template = Template.fromStack(stack) + }) + + test("it has correct runtime", () => { + template.hasResourceProperties("AWS::Lambda::Function", { + Runtime: "nodejs22.x", + FunctionName: "testLambda" + }) + }) +})