Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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] - "

Expand All @@ -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:
Expand All @@ -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] - "
prefix: "Upgrade: [dependabot] - "
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nodejs 22.20.0
nodejs 24.11.1
python 3.12.7
poetry 1.8.3
shellcheck 0.10.0
Expand Down
23 changes: 16 additions & 7 deletions packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -278,7 +287,7 @@ export class TypescriptLambdaFunction extends Construct {
COMMIT_ID: commitId
},
logGroup,
layers:[
layers: [
insightsLambdaLayer,
...layers
]
Expand Down
41 changes: 36 additions & 5 deletions packages/cdkConstructs/tests/functionConstruct.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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"}}
})
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -289,11 +289,42 @@ 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"],
Timeout: 120
})
})
})

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"
})
})
})