Skip to content

fix: ApiStack default stage must depend on its throttled routes - #5

Merged
ezekielelvis merged 1 commit into
mainfrom
fix/api-stage-route-dependency
Aug 2, 2026
Merged

ezekielelvis merged 1 commit into
mainfrom
fix/api-stage-route-dependency

Conversation

@ezekielelvis

Copy link
Copy Markdown
Contributor

Summary

  • After fix: break circular CFN dependency in AuthStack #4 fixed the Auth circular dependency, the pipeline got further but EventTicketing-dev-Api failed to create:
    CREATE_FAILED | AWS::ApiGatewayV2::Stage | DefaultStage
    Unable to find Route by key POST /auth/confirm-signup within the provided RouteSettings
    
  • Root cause: DefaultStage's RouteSettings CFN property override referenced routes by literal string key ('POST /auth/confirm-signup', etc.), which the ApiGatewayV2 Stage handler validates against routes that already exist at creation time. Nothing in the template told CloudFormation the Stage had to wait for those Route resources — a literal string key creates no CDK/CFN dependency edge — so the Stage could (and did) get created before its routes.

Fix

  • Build the RouteSettings map from the actual HttpRoute objects returned by addRoutes() as each route is created in the loop, and call defaultStage.node.addDependency() on the throttled ones at the same time, instead of hardcoding the whole RouteSettings object up front before any routes exist.

Verification

  • pnpm run typecheck, pnpm run lint, pnpm run synth all pass.
  • Inspected the synthesized EventTicketing-dev-Api template directly: DefaultStage now has an explicit DependsOn covering all 7 throttled routes' Route/Integration/Permission resources (21 entries), and RouteSettings keys match those routes 1:1.

Test plan

  • Merge to main, let CI pass, confirm deploy.yml creates EventTicketing-dev-Api successfully this time (Auth already deploys cleanly per fix: break circular CFN dependency in AuthStack #4)
  • Confirm Monitoring and deploy-frontend then complete and the site is reachable

🤖 Generated with Claude Code

Second deploy failure after #4: EventTicketing-dev-Api CREATE_FAILED on
the DefaultStage resource — "Unable to find Route by key POST
/auth/confirm-signup within the provided RouteSettings". The stage's
RouteSettings override referenced routes by literal string key, which
CloudFormation validates against routes that already exist — but nothing
told CFN the Stage had to wait for those Route resources, so it could be
created/updated before them.

Fix: build the RouteSettings map from the actual HttpRoute objects
returned by addRoutes() as routes are created, and add an explicit
defaultStage.node.addDependency() for each throttled route at the same
time. Confirmed in the synthesized template: DefaultStage now has an
explicit DependsOn covering all 7 throttled routes' Route/Integration/
Permission resources, and RouteSettings keys match 1:1.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ezekielelvis! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@ezekielelvis
ezekielelvis merged commit b90f8c5 into main Aug 2, 2026
2 checks passed
@ezekielelvis
ezekielelvis deleted the fix/api-stage-route-dependency branch August 2, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant