Skip to content

feat(gen2-migration): generate IAM auth grant for Gen1 AppSync API#14778

Open
sai-ray wants to merge 1 commit intogen2-migrationfrom
sai/codegen-iam-appsync-grant
Open

feat(gen2-migration): generate IAM auth grant for Gen1 AppSync API#14778
sai-ray wants to merge 1 commit intogen2-migrationfrom
sai/codegen-iam-appsync-grant

Conversation

@sai-ray
Copy link
Copy Markdown
Contributor

@sai-ray sai-ray commented Apr 13, 2026

Fixes: #14518

Description of changes

When a Gen1 AppSync API uses AWS_IAM authentication mode, the generate step now automatically adds an IAM policy granting the Gen2 authenticated user role appsync:GraphQL access to the Gen1 API.

Post-refactor, the identity pool moves to the Gen2 stack with a new auth role. This role has no access to the Gen1 AppSync API, causing IAM-authenticated frontend requests to fail. Previously this was a manual post-generate step documented in the migration guide.

IAM auth detection and grant generation

DataGenerator checks if AWS_IAM is the default or additional auth mode on the Gen1 AppSync API. If it is (and an auth category exists), it contributes a addToPrincipalPolicy statement to backend.ts that grants appsync:GraphQL on the Gen1 API ARN. The Gen1 API ID is hardcoded as a string literal since it references a resource external to the Gen2 stack.

Snapshot cleanup

The product-catalog app's manual addGen1AppSyncPolicy() and resolveGen1AppSyncApiId() post-generate functions are removed, along with the @aws-sdk/client-appsync import. The codegen handles it automatically now.

Issue #, if available

#14518

Description of how you validated changes

  • All 12 generate snapshot tests pass (product-catalog now expects the IAM grant in backend.ts)
  • No other apps affected (only product-catalog has AWS_IAM auth mode)

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

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

AppSync API

When a Gen1 AppSync API uses AWS_IAM authentication, the
generate step now automatically adds an IAM policy granting
the Gen2 authenticated user role appsync:GraphQL access to
the Gen1 API. This is required post-refactor because the
identity pool moves to the Gen2 stack with a new auth role
that has no access to the Gen1 API.

The DataGenerator detects AWS_IAM as default or additional
auth mode and contributes the policy statement to
backend.ts via BackendGenerator. The Gen1 API ID is
hardcoded as a string literal since it references an
external resource.

Removes the manual addGen1AppSyncPolicy() post-generate
step from the product-catalog app.

All 12 generate snapshot tests pass.
---
Prompt: Implement codegen for IAM auth grant when Gen1
AppSync API uses AWS_IAM authentication mode. The generate
step should detect AWS_IAM and add the policy statement
granting the Gen2 auth role access to the Gen1 API.
@sai-ray sai-ray requested a review from a team as a code owner April 13, 2026 21:12
@sai-ray sai-ray changed the title feat(gen2-migration): generate IAM auth grant for Gen1 feat(gen2-migration): generate IAM auth grant for Gen1 AppSync API Apr 13, 2026
@sai-ray sai-ray enabled auto-merge (squash) April 13, 2026 21:24
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