Skip to content

fix(cli): generate admin queries auth wiring - #14909

Merged
sharonyajain merged 2 commits into
aws-amplify:devfrom
hariharan077:fix-14757-admin-queries-rest-api
Sep 7, 2026
Merged

sharonyajain merged 2 commits into
aws-amplify:devfrom
hariharan077:fix-14757-admin-queries-rest-api

Conversation

@hariharan077

Copy link
Copy Markdown
Contributor

Description of changes

Fixes #14757.

When Gen1 AdminQueries REST APIs are generated for Gen2 migration, the generated REST API resource needs to preserve the Cognito behavior that AdminQueries depends on. This updates the REST API generator to detect AdminQueries APIs and emit the missing pieces:

  • API-level CORS preflight options so the proxy resource handles OPTIONS
  • a Cognito User Pools authorizer using the Authorization header
  • Cognito authorization method options with the aws.cognito.signin.user.admin scope
  • explicit ANY methods on the root/proxy resources using the Cognito method options
  • Cognito admin/list IAM permissions for the backing AdminQueries Lambda, scoped to the Gen2 user pool and the Gen1 user pool id when available

Regular REST API generation is left unchanged unless the API is AdminQueries or uses an AdminQueries* backing function.

Description of how you validated changes

  • PATH="$PWD/node_modules/.bin:$PATH" corepack yarn workspace @aws-amplify/cli-internal test src/__tests__/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.test.ts --runInBand --no-coverage
  • PATH="$PWD/node_modules/.bin:$PATH" corepack yarn prettier --check packages/amplify-cli/src/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.ts packages/amplify-cli/src/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.ts packages/amplify-cli/src/__tests__/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.test.ts
  • PATH="$PWD/node_modules/.bin:$PATH" corepack yarn eslint packages/amplify-cli/src/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.ts packages/amplify-cli/src/commands/gen2-migration/generate/amplify/rest-api/rest-api.renderer.ts packages/amplify-cli/src/__tests__/commands/gen2-migration/generate/amplify/rest-api/rest-api.generator.test.ts --max-warnings=1500
  • git diff --check
  • PATH="$PWD/node_modules/.bin:$PATH" corepack yarn sanitize-migration-apps
  • PATH="$PWD/node_modules/.bin:$PATH" corepack yarn build-tests-changed

Note: the first build-tests-changed run hit an NX daemon restart message; rerunning the same command succeeded. Local git hooks call a plain yarn binary directly, while this environment exposes Yarn through Corepack, so commit/push hooks were bypassed after running the hook commands above manually.

Checklist

  • PR description included
  • Tests are changed or added

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

Require canonical AdminQueries dependencies before generating auth.
Generate IAM policies only for verified metadata.
Build Gen1 user pool ARNs with CDK's partition-aware formatter.
Warn when the referenced pool is unavailable.

Cover prefix collisions, absent auth, missing pool IDs, and full output
snapshots. Validate with the cli-internal build and full unit suite.
---
Prompt: do it. make sure you verify and test if its all working by
reproducing the error and the patch before pushing and then comment and
reply whatever is necessary you have my approval
@sharonyajain
sharonyajain self-requested a review September 7, 2026 12:15
@sharonyajain
sharonyajain merged commit 7779fe3 into aws-amplify:dev Sep 7, 2026
5 checks passed
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 incorrectly handles Admin queries in auth definition

2 participants