简体   繁体   English

AWS CDK - API 网关 lambda 调用

[英]AWS CDK - API gateway lambda invoke

I'm using AWS CDK v2 for deploying the stack which has a Lambda and rest API gateway.我正在使用 AWS CDK v2 部署具有 Lambda 和 rest API 网关的堆栈。
When I'm deploying the stack, I'm getting following error:当我部署堆栈时,出现以下错误:

The final policy size (20798) is bigger than the limit (20480). (Service: AWSLambdaInternal; Status Code: 400; Error Code: PolicyLengthExceededException

If I understand correctly AWS CDK automatically generates the resource policy for API gateway resources and attached it to lambda permission.如果我理解正确,AWS CDK 会自动为 API 网关资源生成资源策略并将其附加到 lambda 权限。 As there are many APIs, I'm getting this error.由于有很多 API,我收到此错误。

I'm trying to create an inline policy and attach it to lambda directly.我正在尝试创建一个内联策略并将其直接附加到 lambda。 But I'm not sure how to disable the policy which is automatically getting generated for API gateway by AWS CDK.但我不确定如何禁用 AWS CDK 为 API 网关自动生成的策略。

Thanks for the help!谢谢您的帮助!

Based on your information根据您的信息

I have multiple endpoints in api gateway which is pointing to same lambda.我在 api 网关中有多个端点指向同一个 lambda。

You can create multiple lambda functions pointing to the same source code and use them as API endpoint integrations.您可以创建指向相同源代码的多个 lambda 函数,并将它们用作 API 端点集成。 This will prevent the policy of the given function to be too big.这将防止给定的 function 的策略太大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM