[英]Direct traffic to Lambda function with API Gateway in CDK
我正在嘗試創建一個 REST API 以使用 Lambda function 將數據返回到我的前端,所有這些都在 CDK 中完成。
基本上我的 api-gateway 會將流量從 /uploads 路由到我的 Lambda function。但是,我在合並這個時遇到了一些困難。
const s3UploaderUrlLambda = new lambda.Function(
//defined my Lambda function
);
const api = new apigateway.LambdaRestApi(this, 's3uploader', {
handler: s3UploaderUrlLambda, //I believe this handler means that it will target this
//Lambda for every single route but I only want it for /uploads
proxy: false
});
const uploads = api.root.addResource('uploads');
uploads.addMethod('GET')
誰能幫忙?
定義資源的默認集成:
const uploads = api.root.addResource('uploads', {
defaultIntegration: new apigateway.LambdaIntegration(
s3UploaderUrlLambda
)
});
或直接用於方法:
uploads.addMethod(
'GET',
new apigateway.LambdaIntegration(
s3UploaderUrlLambda
)
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.