Skip to content

fix(amplify-provider-awscloudformation): preserve GraphQLSchema logical id on v1 to v2 migration - #14963

Open
sarayev wants to merge 1 commit into
devfrom
fix/gen1-v1v2-graphqlschema-logicalid
Open

fix(amplify-provider-awscloudformation): preserve GraphQLSchema logical id on v1 to v2 migration#14963
sarayev wants to merge 1 commit into
devfrom
fix/gen1-v1v2-graphqlschema-logicalid

Conversation

@sarayev

@sarayev sarayev commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description of changes

Deploy-time, migration-gated fix in the Gen1 CLI for the v1 to v2
AWS::AppSync::GraphQLSchema logical-ID collision.

On a v1 to v2 GraphQL transformer migration the schema resource's
logical ID changes from v1's hard-coded GraphQLSchema to v2's
CDK-hashed GraphQLAPITransformerSchema<hash>. Because the schema's
physical ID is <apiId>GraphQLSchema (one per API), CloudFormation
attempts a create-before-delete on the rename and fails with
CREATE_FAILED: <apiId>GraphQLSchema already exists, rolling back the
migration deployment.

The fix adds a whole-template pass in preProcessCFNTemplate that runs
only when the previously-deployed API template still has the schema
at logical ID GraphQLSchema. In that case it rewrites the hashed
logical ID back to GraphQLSchema and fixes every reference (Ref,
DependsOn, Fn::GetAtt, Fn::Sub) — so CloudFormation performs an
in-place update instead of a colliding replacement.

The rewrite is migration-gated. Born-v2 Gen1 apps, brand-new APIs,
non-API/nested-stack templates, and Gen2/CDK consumers are unaffected
and produce byte-identical output. The change is confined to
amplify-provider-awscloudformation; transformer packages are
untouched.

Issue #, if available

N/A

Description of how you validated changes

  • 5 new unit tests for preserveGraphQLSchemaLogicalId, including a
    born-v2 byte-identical (no-op) case; all pass.
  • Existing amplify-provider-awscloudformation suite green.
  • Live v1 to v2 migration e2e on a real account reached
    UPDATE_COMPLETE, the schema resource stayed at
    LogicalResourceId=GraphQLSchema, and no logical-ID collision
    occurred.

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.

…al id on v1 to v2 migration

On a Gen1 v1 to v2 GraphQL transformer migration the AppSync schema
resource's logical id changes from v1's hard-coded `GraphQLSchema` to
the v2 CDK-hashed `GraphQLAPITransformerSchema<hash>`. Because the
schema's physical id (`<apiId>GraphQLSchema`) is unique per API,
CloudFormation attempts a create-before-delete on the rename and fails
with CREATE_FAILED `<apiId>GraphQLSchema already exists`, rolling back
the deployment.

This adds a whole-template pass in `preProcessCFNTemplate` that runs
only when the previously-deployed API template still has the schema at
logical id `GraphQLSchema`. In that case it rewrites the hashed logical
id back to `GraphQLSchema` and fixes every reference (Ref, DependsOn,
Fn::GetAtt, Fn::Sub) so CloudFormation performs an in-place update
instead of a colliding replacement.

The rewrite is migration-gated: born-v2 Gen1 apps, brand-new APIs,
non-API templates, and Gen2/CDK consumers are unaffected and produce
byte-identical output. The change is confined to
amplify-provider-awscloudformation; transformer packages are untouched.

---
Prompt: Fix the Gen1 v1 to v2 AppSync GraphQLSchema logical-ID
collision entirely within the amplify-cli repo (deploy-time,
migration-gated), non-breaking for born-v2 customers; prepare a PR.
@sarayev
sarayev marked this pull request as ready for review July 22, 2026 14:14
@sarayev
sarayev requested a review from a team as a code owner July 22, 2026 14:14
@sarayev
sarayev enabled auto-merge (squash) July 23, 2026 15:38

@svidgen svidgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd. What's the reason this broke? This v1 -> v2 flow has been around for years.

What's the implication on running amplify push --force? (IIRC, this can be used to skip a missing or corrupt #current-cloud-backend/ state.)

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.

3 participants