I've created a lambda function called add
in my aws environment, I am trying to build a cdk application that would generate a new API Gateway and then invoke add
.
I am following the tutorial on https://cdkworkshop.com/20-typescript/30-hello-cdk/300-apigw.html and I noticed all the examples I came across online seem to write their code in a similar form to following:
const hello = new lambda.Function(this, 'HelloHandler', {
runtime: lambda.Runtime.NODEJS_10_X, // execution environment
code: lambda.Code.fromAsset('lambda'), // code loaded from "lambda" directory
handler: 'hello.handler' // file is "hello", function is "handler"
});
const api = new apiGateWay.LambdaRestApi(this, 'api', {
handler: hello
})
Above example directly creates a new lambda function name with HelloHanlder
in it. I want to reference my previously created function add
, and not add any new lambda function to the stack, something along the lines of:
const api = new apiGateWay.LambdaRestApi(this, 'api', {
handler: "add"
})
Is this possible to fix?