add
내 aws 환경에서 호출되는 람다 함수를 생성했으며 새 API 게이트웨이를 생성 한 다음를 호출하는 cdk 애플리케이션을 빌드하려고합니다 add
.
https://cdkworkshop.com/20-typescript/30-hello-cdk/300-apigw.html 의 자습서를 따르고 있으며 온라인에서 찾은 모든 예제가 다음과 유사한 형식으로 코드를 작성하는 것으로 보입니다. :
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
})
위의 예제는 새로운 람다 함수 이름을 직접 만듭니다 HelloHanlder
. 이전에 만든 함수를 참조 add
하고 새로운 람다 함수를 스택에 추가하지 않으려 고합니다.
const api = new apiGateWay.LambdaRestApi(this, 'api', {
handler: "add"
})
이것이 고칠 수 있습니까?
옵션 1 : Arn 함수에서 기존 Lambda 사용
const hello = lambda.Function.fromFunctionArn(
this,
"hello-lambda",
"arn:aws:lambda:us-east-1:111222233333:function:hello-lambda"
);
new apigw.LambdaRestApi(this, "Endpoint", {
handler: hello,
});
옵션 2 : 기존 람다를 새 CloudFormation 스택으로 가져오고 Arn을 내보내고 CDK로 가져올 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다