-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
For the Lambda ApiGateway integration, add an option to prefer a single wildcard trigger/integrationPermission instead of multiple triggers/integrationPermissions for each URL/endpoint/resource defined in the ApiGateway.
Currently the created triggers in the AWS console looks like that:
arn:aws:execute-api:us-east-1:123:api_id/prod/GET/v1/parent_res_1/*
arn:aws:execute-api:us-east-1:123:api_id/prod/POST/v1/parent_res_1/*
arn:aws:execute-api:us-east-1:123:api_id/prod/GET/v1/parent_res_2/*
...
The requested feature would allow to have something like that instead:
arn:aws:execute-api:us-east-1:123:api_id/*
Use Case
In case of APIs with a larger amount of urls/endpoints/resources, it is likely to get a "The final policy size (XXX) is bigger than the limit (20480)" error.
In our case, we run into that for an API with around 15 resources and worked around temporarily by setting LambdaIntegrationOptions.allowTestInvoke to false. This cut the number of triggers/IntegrationPermissions in half and the policy didn't hit the limit anymore.
However, we would prefer leaving allowTestInvoke to true.
Moreover as the API grows over time, we will likely run into the same issue again later: the faster the API grows, the sooner. Implementing something like described in #5774 (comment) (also see below) currently seems to be something like a last resort for us.
Implication of the current state of CDK in this respect for us is that the CDK ApiGateway -> LambdaIntegration cannot be easily used for APIs with a considerable amount of endpoints because the CDK stack will break sooner or later when adding more resources to the APIGateway.
Proposed Solution
- Add
booleanoptionsingleWildcardTriggerorsingleWildcardIntegrationPermissiontoaws_cdk.aws_apigateway.LambdaIntegrationOptions. - Per default, it is
falseand everything works like as it does currently. - In case of
true, only a single trigger with wildcards is generated (see above). - With the existing
allowTestInvokeoption, there is already an option which works globally an all tiggers/integrationPermissions as well. So something very similar is already available.
Other
There is a similar (duplicate?) issue which as been closed already #5774 (closed #5774 (comment) by AWS).
The discussions in the end (after closing by AWS) are about workarounds (subclassing CDK) for something which seems to be missing as a feature, thus I created a new issue. Feel free to reopen the original one and add this as a duplicate.
Please also check #5774 (comment) which has been added after closing the issue. This comment describes the problem exactly the same as we see it.
This is a 🚀 Feature Request