You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS CDK中apigatewayv2-integrations报LambdaProxyIntegration不存在错误

解决apigatewayv2-integrations中“Property 'LambdaProxyIntegration' does not exist on type 'typeof'”错误

错误根源

你使用的LambdaProxyIntegration是AWS CDK v1中为REST API Gateway设计的集成类,但你当前构建的是HTTP API Gateway(apigw.HttpApi),二者不匹配。此外,CDK v2中针对HTTP API的Lambda集成类已更名为HttpLambdaIntegration,旧类名不再适用。

修复代码

将API Gateway部分的集成代码替换为以下内容:

// 创建API Gateway及默认路径/方法
const api = new apigw.HttpApi(this, 'Endpoint', {
  defaultIntegration: new integrations.HttpLambdaIntegration('LambdaIntegration', postFn),
});

关键说明

  • HttpLambdaIntegration的构造参数顺序与旧类不同:第一个参数是集成的唯一标识ID,第二个参数才是目标Lambda函数
  • 你的Lambda运行时NODEJS_12_X已被AWS官方弃用,建议升级至NODEJS_20_X或其他受支持的版本
  • cluster.secret?.secretArn存在空值风险,建议添加非空断言(!)或空值处理逻辑,避免部署时出现警告

内容的提问来源于stack exchange,提问作者Sorab

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 11:48:35