feat(apigatewayv2): add dedupeHandlers to reuse Integration + Function across routes#6914
Open
brentrager wants to merge 1 commit into
Open
feat(apigatewayv2): add dedupeHandlers to reuse Integration + Function across routes#6914brentrager wants to merge 1 commit into
brentrager wants to merge 1 commit into
Conversation
…n across routes AWS HTTP APIs cap Integrations per API at 300 — a hard cap that is NOT adjustable through Service Quotas (only Routes are, via L-65B5C802). Today every route() call creates a new Integration + Lambda + Permission even when the handler string is identical, so splitting routes for clarity (different auth, rate limits, etc.) burns Integration slots unnecessarily. On large monorepos this is the real scaling ceiling people hit. Add an opt-in `dedupeHandlers: true` flag on ApiGatewayV2. When set, the Nth route() call against the same handler string reuses the first call's Integration + Function + Permission and only creates a new apigatewayv2.Route. Routes stay capped (default 300, raisable to 1000+) but Integrations stay at exactly one per unique handler. The route component keeps a stable URN across the dedup boundary (no separate shared-route component), so migrating an existing app from non-dedup state doesn't make Pulumi recreate routes and hit ConflictException at API Gateway. Refs anomalyco#4559 (duplicate per-route resources). Same approach aws-cdk took in aws/aws-cdk#12528 (dedupe HTTP integrations per route).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6913.
Problem
AWS HTTP APIs cap Integrations at 300 per API — and unlike the Routes quota (
L-65B5C802, raisable to 1000+), the Integrations cap is hard, not adjustable via Service Quotas. Today everyroute()creates a new Integration + Lambda + Permission even when routes share the same handler, so splitting routes for clarity (different auth, rate limits, OpenAPI grouping) burns Integration slots. On large monorepos you hit 300 well before you have 300 distinct handlers. Same duplicate-resource-per-route class as #4559; aws-cdk fixed the analogue in aws/aws-cdk#12528.Solution
Opt-in
dedupeHandlers: trueonApiGatewayV2:When set, the Nth
route()against the same handler string reuses the first call's Integration + Function + Permission and only creates a newapigatewayv2.Route. Routes stay capped (default 300, raisable to 1000+); Integrations stay at exactly one per unique handler — the actual scaling ceiling. Default isfalse, so behavior is unchanged unless opted in.URN stability
The route component keeps a stable URN across the dedup boundary (it does not spawn a separate shared-route component for routes 2-N). This means an existing app can flip
dedupeHandlers: truewithout Pulumi seeing the route's parent URN change — which would otherwise make it try to create the newapigatewayv2.Routebefore deleting the old one and fail withConflictException("Route with key X already exists").Notes
apigatewayv2.ts+apigatewayv2-lambda-route.ts. Typechecks clean (tsc --noEmit).apigatewayv2has no existing tests inplatform/test/components/. Happy to add a synth-based test asserting "N routes / same handler → 1 Integration" if you'd like it for this PR — just didn't want to introduce a bespoke pattern unprompted.