Skip to content

fix(cli): paginate API Gateway resources when resolving REST API root resource - #14967

Open
vishwakt wants to merge 1 commit into
aws-amplify:devfrom
vishwakt:fix/gen2-migration-rest-api-root-pagination
Open

fix(cli): paginate API Gateway resources when resolving REST API root resource#14967
vishwakt wants to merge 1 commit into
aws-amplify:devfrom
vishwakt:fix/gen2-migration-rest-api-root-pagination

Conversation

@vishwakt

Copy link
Copy Markdown

Description of changes

fetchRestApiRootResourceId called API Gateway GetResources once and never followed the pagination token. API Gateway returns 25 resources per page by default with no ordering guarantee, so on REST APIs with more than 25 resources the root / resource can land on a later page and gen2-migration generate or assess fails with "Root resource not found for REST API" even though the API is healthy.

This change uses paginateGetResources to walk pages until the root resource is found, returning early once it is. This matches the paginator pattern already used in aws-fetcher.ts for CloudFormation and Cognito calls.

Issue #, if available

Fixes #14948

Description of how you validated changes

Added unit tests for fetchRestApiRootResourceId covering:

  • root resource on the first page
  • root resource on a later page, verifying the pagination token is passed through
  • root resource missing from all pages, verifying RestApiResourceNotFoundError is thrown

All existing gen2-migration REST API generator and infra tests pass.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

gen2-migration generate/assess fails with "Root resource not found for REST API" on APIs with >25 resources (missing pagination)

1 participant