Skip to content

Instantly share code, notes, and snippets.

@apoorvmote
Last active February 22, 2021 15:14
Show Gist options
  • Save apoorvmote/452d16af51682f41f044624ff3dd9c3d to your computer and use it in GitHub Desktop.
Save apoorvmote/452d16af51682f41f044624ff3dd9c3d to your computer and use it in GitHub Desktop.
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'
export async function myFunction(event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> {
return {
statusCode: 200,
body: JSON.stringify({ message: 'hello from ts lambda' })
}
}
import { Runtime } from '@aws-cdk/aws-lambda';
import { NodejsFunction } from '@aws-cdk/aws-lambda-nodejs';
import * as cdk from '@aws-cdk/core';
export class TsLambdaStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// The code that defines your stack goes here
new NodejsFunction(this, 'helloWorldFn', {
runtime: Runtime.NODEJS_14_X,
entry: `${__dirname}/../lambda-fns/hello-world/index.ts`,
handler: 'myFunction',
memorySize: 128,
bundling: {
minify: true,
tsconfig: `${__dirname}/../lambda-fns/hello-world/tsconfig.json` // optional if you want to override defaults
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment