File tree Expand file tree Collapse file tree
aws.iac/src/resources/lambda Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @notation/aws.iac " : minor
3+ " @notation/aws " : minor
4+ ---
5+
6+ Support alternative runtimes
Original file line number Diff line number Diff line change 1+ import json
2+
3+ def handler (event , context ):
4+ print ("event" , event )
5+ return {
6+ 'statusCode' : 200 ,
7+ 'body' : json .dumps ({'message' : 'Hello, world!' })
8+ }
Original file line number Diff line number Diff line change 11import { api , router } from "@notation/aws/api-gateway" ;
2- import { externalJsLambda , externalZipLambda } from "./lambda" ;
2+ import {
3+ externalJsLambda ,
4+ externalZipLambda ,
5+ externalPyLambda ,
6+ } from "./lambda" ;
37
48const helloApi = api ( { name : "hello-api" } ) ;
59const helloRouter = router ( helloApi ) ;
610
711helloRouter . get ( "/hello1" , externalJsLambda ) ;
812helloRouter . get ( "/hello2" , externalZipLambda ) ;
13+ helloRouter . get ( "/hello3" , externalPyLambda ) ;
Original file line number Diff line number Diff line change @@ -17,3 +17,13 @@ export const externalZipLambda = lambda({
1717 path : "external/lambda.zip" ,
1818 } ,
1919} ) ;
20+
21+ export const externalPyLambda = lambda ( {
22+ id : "external-py" ,
23+ handler : "handler" ,
24+ code : {
25+ type : "file" ,
26+ path : "external/lambda.py" ,
27+ } ,
28+ runtime : "python3.12" ,
29+ } ) ;
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ const lambdaFunctionSchema = lambdaFunction.defineSchema({
188188 Runtime : {
189189 valueType : z . enum ( [
190190 "dotnet6" ,
191+ "dotnet8" ,
191192 "dotnetcore1.0" ,
192193 "dotnetcore2.0" ,
193194 "dotnetcore2.1" ,
@@ -205,6 +206,7 @@ const lambdaFunctionSchema = lambdaFunction.defineSchema({
205206 "nodejs16.x" ,
206207 "nodejs18.x" ,
207208 "nodejs20.x" ,
209+ "nodejs22.x" ,
208210 "nodejs4.3" ,
209211 "nodejs4.3-edge" ,
210212 "nodejs6.10" ,
@@ -216,13 +218,15 @@ const lambdaFunctionSchema = lambdaFunction.defineSchema({
216218 "python3.10" ,
217219 "python3.11" ,
218220 "python3.12" ,
221+ "python3.13" ,
219222 "python3.6" ,
220223 "python3.7" ,
221224 "python3.8" ,
222225 "python3.9" ,
223226 "ruby2.5" ,
224227 "ruby2.7" ,
225228 "ruby3.2" ,
229+ "ruby3.3" ,
226230 ] ) ,
227231 propertyType : "param" ,
228232 presence : "optional" ,
@@ -381,3 +385,7 @@ export const LambdaFunction = lambdaFunctionSchema
381385 } ) ) ;
382386
383387export type LambdaFunctionInstance = InstanceType < typeof LambdaFunction > ;
388+
389+ export type LambdaFunctionConfig = ConstructorParameters <
390+ typeof LambdaFunction
391+ > [ 0 ] [ "config" ] ;
Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ type LambdaConfig = {
1010 type : "file" | "zip" ;
1111 path : string ;
1212 } ;
13+ runtime ?: aws . lambda . LambdaFunctionConfig [ "Runtime" ] ;
1314} ;
1415
15- export const lambda = ( config : LambdaConfig ) => {
16+ export const lambda = ( config : LambdaConfig ) : aws . AwsResourceGroup => {
1617 const functionGroup = new aws . AwsResourceGroup ( "Lambda" , { config } ) ;
1718 const filePath = config . code . path ;
1819
@@ -63,14 +64,15 @@ export const lambda = (config: LambdaConfig) => {
6364 ) ;
6465
6566 const fileName = path . parse ( filePath ) . name ;
67+ const runtime = config . runtime || "nodejs22.x" ;
6668
6769 const lambdaResource = functionGroup . add (
6870 new aws . lambda . LambdaFunction ( {
6971 id : lambdaId ,
7072 config : {
7173 FunctionName : lambdaId ,
7274 Handler : `${ fileName } .${ config . handler } ` ,
73- Runtime : "nodejs18.x" ,
75+ Runtime : runtime ,
7476 // todo: make this configurable and remove it as a default
7577 ReservedConcurrentExecutions : 1 ,
7678 } ,
You can’t perform that action at this time.
0 commit comments