Skip to content

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

Description

@rvtraveller

How did you install the Amplify CLI?

NPM

If applicable, what version of Node.js are you using?

22.22.3

Amplify CLI Version

14.5.1

What operating system are you using?

MacOs

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

When running amplify gen2-migration generate I receive the error:

→ Planning failed

🛑 Root resource not found for REST API '<redacted>'

fetchRestApiRootResourceId() in packages/amplify-cli/src/commands/gen2-migration/_common/aws-fetcher.ts (lines 192–198) calls API Gateway's GetResourcesCommand exactly once with no pagination:

public async fetchRestApiRootResourceId(restApiId: string): Promise<string> {
  const { items } = await this.clients.apiGateway.send(new GetResourcesCommand({ restApiId }));
  const root = items?.find((r) => r.path === '/');
  if (!root?.id) {
    throw new AmplifyError('RestApiResourceNotFoundError', {
      message: `Root resource not found for REST API '${restApiId}'`,

GetResources paginates server-side (default page size 25, returns a position token) and item ordering isn't guaranteed to put / first. On any REST API with more than ~25 resources, / can land past page 1, this call never follows position, and generate/assess fails even though the API and its root resource are completely healthy.

Expected behavior

amplify gen2-migration generate is able to run without error on large REST APIs

Reproduction steps

Any Gen1 REST API category with 25+ Lambda-backed paths reproduces this. In our case (75 resources), root resource sits at position 66 in id order — confirmed via direct aws apigateway get-resources --no-paginate returning only 25 items, no root, with a position token present signaling more pages.

Project Identifier

No response

Log output

Details
# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions