-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.ts
More file actions
24 lines (18 loc) · 842 Bytes
/
Copy pathstack.ts
File metadata and controls
24 lines (18 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { App, Stack } from 'aws-cdk-lib'
import { LambdaIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway'
import { Runtime } from 'aws-cdk-lib/aws-lambda'
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'
const serverlessApiStack = (app: App) => {
const stack = new Stack(app, 'LambdaApiHelloWorldStack', { stackName: "LambdaApiHelloWorldStack" })
const lambdaFunction = new NodejsFunction(stack, 'HelloWorldFunction', {
entry: 'helloWorld.ts',
runtime: Runtime.NODEJS_16_X,
})
const api = new RestApi(stack, "RestApi", {});
const helloWorldIntegration = new LambdaIntegration(lambdaFunction, {
requestTemplates: { "application/json": '{ "statusCode": "200" }' }
});
api.root.addMethod("GET", helloWorldIntegration);
}
const app = new App()
serverlessApiStack(app)