Skip to content

chore(gen2-migration): add changes to product-catalog app#14714

Draft
sanjanaravikumar-az wants to merge 4 commits intogen2-migrationfrom
sanjrkmr/product-catalog-e2e
Draft

chore(gen2-migration): add changes to product-catalog app#14714
sanjanaravikumar-az wants to merge 4 commits intogen2-migrationfrom
sanjrkmr/product-catalog-e2e

Conversation

@sanjanaravikumar-az
Copy link
Copy Markdown
Contributor

Description of changes

Adds e2e migration support for the product-catalog app. This app uses IAM as the default GraphQL auth mode with Lambda functions that call back into the AppSync API, which requires additional wiring that the e2e system's addFunction (Hello World template) doesn't provide.

Why these changes are needed:

The e2e system creates Lambda functions using the Hello World template without configuring API access, secrets, or environment variables through the interactive CLI prompts. The manual setup (per the README) uses amplify add function with "Yes" to advanced settings, which automatically wires up CFN parameters, IAM policies, env vars, and secret paths. The changes below compensate for that gap.

App-level changes (amplify-migration-apps/product-catalog/):

  • configure.sh:

    • Dynamically discovers API directory name (generated, not hardcoded).
    • Resolves custom-roles.json placeholder using deployment name from project-config.json.
    • Patches Lambda CFN templates with SSM policy, API env vars, appsync:GraphQL permission, and dependsOn wiring in backend-config.json and function-parameters.json.
  • custom-roles.json:

    • Adds Lambda execution role prefix and Gen2 auth role pattern (amplifyAuthauthenticatedU) as admin roles.
    • The Lambda role needs AppSync admin access for IAM-signed GraphQL calls.
    • The Gen2 auth role prefix is needed after refactor because IAM truncates the role name at 64 chars, breaking the original prefix match.
  • lowstockproducts.js:

    • Replaces hardcoded env var name with dynamic scan for API_*_GRAPHQLAPIENDPOINTOUTPUT.
    • Replaces ListGraphqlApis SDK discovery with event host header extraction — the original approach picked up stale APIs from previous test runs.
  • onimageuploaded.js:

    • Same dynamic env var fallback for the S3 trigger Lambda.
  • post-generate.ts:

    • Automates the README's "Migrating to Gen2"
      edits: branchName → sandbox, aws_iam import + appsync:GraphQL policy, userPoolConfig awsRegion fix lowstockproducts ESM conversion + secret(), S3 trigger ESM conversion, frontend import update.
  • post-refactor.ts:

    • Uncomments s3Bucket.bucketName in backend.ts after refactor (same as project-boards).

E2e system changes:

  • category-initializer.ts:

    • Fixes auth mode ordering — builds authTypesConfig in the order specified by migration-config.json so the first auth mode becomes the default (was always defaulting to API_KEY).

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

@sanjanaravikumar-az sanjanaravikumar-az requested a review from a team as a code owner March 29, 2026 01:16
@sanjanaravikumar-az sanjanaravikumar-az marked this pull request as draft March 29, 2026 01:16
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