-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(@aws-cdk/aws-apigatewayv2-alpha): After adding around 30 routes to a http api, I got policy PolicyLengthExceededException #19535
Comments
@tgjorgoski take a look at this issues #9327 it's for apigateway v1, but your are facing a very similar issue |
Hey, we've actually just recently merged a PR which aims to tackle all sorts of policy size limit issues. Look forward to the next v2 release and let me know if this is still an issue 🙂 |
@peterwoodworth , I updated all cdk npm packages (including alpha ones) to 2.18.0 , turned on the feature flag and redeployed. I saw bunch of policies being squished, but unfortunately in the case of the apigateway v2 routes, the optimisation isn't enough. It seems to have done something because the new message says |
@JPLemelin , thanks for the pointer! I will look into it, on a first look seems as a good workaround! |
I used the (somewhat modified) solution from #9327 , and it seems to work: Instead of
And then in the end I added one general policy for all the routes:
|
|
Didn't mean to close this, sorry 😅 |
Thanks for letting me know the issue is still occurring. A bit disappointing to hear |
HttpLambdaIntegration caused the same problem for me as well.
|
I think to some extent there is some overlap with issue #9327 here. I recently looked at switching a project from Serverless Framework to cdk and ended up hitting this issue and as a result I wasn't able to deploy anything while the generated policy was too large. It was quite a pain I'd say but I did manage to figure out a (non-trivial, hacky) workaround which I posted here: #9327 (comment) in case that helps anyone else. For reference I'm using cdk 2.52.0 (cli and libs) |
What is the problem?
I’m creating http api using:
const api = new HttpApi (from '@aws-cdk/aws-apigatewayv2-alpha')
, and then I’m adding routes to it, something like this:I got to around 30 routes, all the routes are connected to one and the same lambda. At which point I got the following exception from the CloudFormation:
If I understand right, CDK adds policy statements for each route to the resource-based policy of the lambda. The statements look like this:
So, it seems they quickly get the total length of the policy document to the max.
I think I will create two CDK lambdas from the same code, and split it among the routes, to somehow solve the immediate problem, but it might be good if the CDK could automatically solve this.
Reproduction Steps
What did you expect to happen?
The routes are proprely created
What actually happened?
Got: Service: AWSLambdaInternal; Status Code: 400; Error Code: PolicyLengthExceededException
CDK CLI Version
2.17.0 (build f9cd009)
Framework Version
No response
Node.js Version
14
OS
Mac OS
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: