Skip to content

Commit b7fa446

Browse files
authored
Fix: [AEA-0000] - add runtime param to typescript function (#387)
## Summary - Routine Change ### Details - add runtime param to typescript function
1 parent eec2812 commit b7fa446

File tree

4 files changed

+63
-17
lines changed

4 files changed

+63
-17
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ updates:
99
# default location of `.github/workflows`
1010
directory: "/"
1111
schedule:
12-
interval: "daily"
12+
interval: "weekly"
13+
day: "friday"
14+
time: "18:00" #UTC
1315
commit-message:
1416
prefix: "Upgrade: [dependabot] - "
1517

@@ -19,7 +21,9 @@ updates:
1921
- package-ecosystem: "npm"
2022
directory: "/"
2123
schedule:
22-
interval: "daily"
24+
interval: "weekly"
25+
day: "friday"
26+
time: "18:00" #UTC
2327
versioning-strategy: increase
2428
open-pull-requests-limit: 20
2529
commit-message:
@@ -31,7 +35,9 @@ updates:
3135
- package-ecosystem: "pip"
3236
directory: "/"
3337
schedule:
34-
interval: "daily"
38+
interval: "weekly"
39+
day: "friday"
40+
time: "18:00" #UTC
3541
versioning-strategy: increase
3642
commit-message:
37-
prefix: "Upgrade: [dependabot] - "
43+
prefix: "Upgrade: [dependabot] - "

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nodejs 22.20.0
1+
nodejs 24.11.1
22
python 3.12.7
33
poetry 1.8.3
44
shellcheck 0.10.0

packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface TypescriptLambdaFunctionProps {
4545
/**
4646
* A map of environment variables to set for the lambda function.
4747
*/
48-
readonly environmentVariables: {[key: string]: string}
48+
readonly environmentVariables: { [key: string]: string }
4949
/**
5050
* Optional additional IAM policies to attach to role the lambda executes as.
5151
*/
@@ -77,15 +77,23 @@ export interface TypescriptLambdaFunctionProps {
7777
* @default 50 seconds
7878
*/
7979
readonly timeoutInSeconds?: number
80+
81+
/**
82+
* Optional runtime for the Lambda function.
83+
* @default Runtime.NODEJS_24_X
84+
*/
85+
readonly runtime?: Runtime
8086
}
8187

8288
const insightsLayerArn = "arn:aws:lambda:eu-west-2:580247275435:layer:LambdaInsightsExtension:60"
8389
const getDefaultLambdaOptions = (
8490
packageBasePath: string,
8591
projectBaseDir: string,
86-
timeoutInSeconds: number):NodejsFunctionProps => {
92+
timeoutInSeconds: number,
93+
runtime: Runtime
94+
): NodejsFunctionProps => {
8795
return {
88-
runtime: Runtime.NODEJS_22_X,
96+
runtime: runtime,
8997
projectRoot: projectBaseDir,
9098
memorySize: 256,
9199
timeout: Duration.seconds(timeoutInSeconds),
@@ -170,7 +178,7 @@ export class TypescriptLambdaFunction extends Construct {
170178
* @param id - The scoped construct ID. Must be unique amongst siblings in the same scope
171179
* @param props - Configuration properties for the Lambda function
172180
*/
173-
public constructor(scope: Construct, id: string, props: TypescriptLambdaFunctionProps){
181+
public constructor(scope: Construct, id: string, props: TypescriptLambdaFunctionProps) {
174182
super(scope, id)
175183

176184
// Destructure with defaults
@@ -186,7 +194,8 @@ export class TypescriptLambdaFunction extends Construct {
186194
commitId,
187195
layers = [], // Default to empty array
188196
projectBaseDir,
189-
timeoutInSeconds = 50
197+
timeoutInSeconds = 50,
198+
runtime = Runtime.NODEJS_24_X
190199
} = props
191200

192201
// Imports
@@ -266,7 +275,7 @@ export class TypescriptLambdaFunction extends Construct {
266275
})
267276

268277
const lambdaFunction = new NodejsFunction(this, functionName, {
269-
...getDefaultLambdaOptions(packageBasePath, projectBaseDir, timeoutInSeconds),
278+
...getDefaultLambdaOptions(packageBasePath, projectBaseDir, timeoutInSeconds, runtime),
270279
functionName: `${functionName}`,
271280
entry: join(projectBaseDir, packageBasePath, entryPoint),
272281
role,
@@ -278,7 +287,7 @@ export class TypescriptLambdaFunction extends Construct {
278287
COMMIT_ID: commitId
279288
},
280289
logGroup,
281-
layers:[
290+
layers: [
282291
insightsLambdaLayer,
283292
...layers
284293
]

packages/cdkConstructs/tests/functionConstruct.test.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {App, assertions, Stack} from "aws-cdk-lib"
22
import {ManagedPolicy, PolicyStatement, Role} from "aws-cdk-lib/aws-iam"
33
import {LogGroup} from "aws-cdk-lib/aws-logs"
4-
import {Function, LayerVersion} from "aws-cdk-lib/aws-lambda"
4+
import {Function, LayerVersion, Runtime} from "aws-cdk-lib/aws-lambda"
55
import {Template, Match} from "aws-cdk-lib/assertions"
66
import {
77
describe,
@@ -114,7 +114,7 @@ describe("functionConstruct works correctly", () => {
114114
test("it has the correct lambda", () => {
115115
template.hasResourceProperties("AWS::Lambda::Function", {
116116
Handler: "index.handler",
117-
Runtime: "nodejs22.x",
117+
Runtime: "nodejs24.x",
118118
FunctionName: "testLambda",
119119
MemorySize: 256,
120120
Architectures: ["x86_64"],
@@ -166,7 +166,7 @@ describe("functionConstruct works correctly with environment variables", () => {
166166

167167
test("environment variables are added correctly", () => {
168168
template.hasResourceProperties("AWS::Lambda::Function", {
169-
Runtime: "nodejs22.x",
169+
Runtime: "nodejs24.x",
170170
FunctionName: "testLambda",
171171
Environment: {Variables: {foo: "bar"}}
172172
})
@@ -249,7 +249,7 @@ describe("functionConstruct works correctly with additional layers", () => {
249249
test("it has the correct layers added", () => {
250250
template.hasResourceProperties("AWS::Lambda::Function", {
251251
Handler: "index.handler",
252-
Runtime: "nodejs22.x",
252+
Runtime: "nodejs24.x",
253253
FunctionName: "testLambda",
254254
MemorySize: 256,
255255
Architectures: ["x86_64"],
@@ -289,11 +289,42 @@ describe("functionConstruct works correctly with custom timeout", () => {
289289
test("it has the correct timeout", () => {
290290
template.hasResourceProperties("AWS::Lambda::Function", {
291291
Handler: "index.handler",
292-
Runtime: "nodejs22.x",
292+
Runtime: "nodejs24.x",
293293
FunctionName: "testLambda",
294294
MemorySize: 256,
295295
Architectures: ["x86_64"],
296296
Timeout: 120
297297
})
298298
})
299299
})
300+
301+
describe("functionConstruct works correctly with different runtime", () => {
302+
let stack: Stack
303+
let app: App
304+
let template: assertions.Template
305+
beforeAll(() => {
306+
app = new App()
307+
stack = new Stack(app, "lambdaConstructStack")
308+
new TypescriptLambdaFunction(stack, "dummyFunction", {
309+
functionName: "testLambda",
310+
additionalPolicies: [],
311+
packageBasePath: "packages/cdkConstructs",
312+
entryPoint: "tests/src/dummyLambda.ts",
313+
environmentVariables: {},
314+
logRetentionInDays: 30,
315+
logLevel: "DEBUG",
316+
version: "1.0.0",
317+
commitId: "abcd1234",
318+
projectBaseDir: resolve(__dirname, "../../.."),
319+
runtime: Runtime.NODEJS_22_X
320+
})
321+
template = Template.fromStack(stack)
322+
})
323+
324+
test("it has correct runtime", () => {
325+
template.hasResourceProperties("AWS::Lambda::Function", {
326+
Runtime: "nodejs22.x",
327+
FunctionName: "testLambda"
328+
})
329+
})
330+
})

0 commit comments

Comments
 (0)