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
相关产品推荐
相关产品推荐

