fix(gen2-migration): lock command shows unexpected drift for apps with REST APIs, auth triggers or S3 triggers#14669
Merged
sai-ray merged 5 commits intogen2-migrationfrom Mar 26, 2026
Conversation
lock commands shows unexpected drift for apps with REST APIs, auth triggers or S3 triggerslock command shows unexpected drift for apps with REST APIs, auth triggers or S3 triggers
…k-command-unexpected-drifts
9pace
reviewed
Mar 16, 2026
9pace
left a comment
There was a problem hiding this comment.
General feedback. Let's talk in person.
9pace
requested changes
Mar 24, 2026
9pace
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #14635, #14483 and #14489
Description of changes
This PR filters three known false-positive drifts in Phase 1 (CloudFormation stack drift) that cause
gen2-migration lockto fail validation on apps with REST APIs, auth triggers, or S3 storage triggers.The false positives are caused by Amplify's own push pipeline:
apigw-stack-builder.ts#generateStackResources(inamplify-category-apirepo) setsdescription: ''onCfnRestApi, but API Gateway resolves it tonullat deploy time. CloudFormation seesActualValue: null,ExpectedValue: ''as drift.createPermissionsForAuthTrigger()(L219) attaches anAddToGroupCognitopolicy (defined inPostConfirmation.map.json) to the Lambda execution role. This appears as/Policies/0drift withExpectedValue: null.configureTriggerPolicy()(L109) attaches anamplify-lambda-execution-policy-storagepolicy (hardcoded increateTriggerPolicyDefinition()(L883)) to the Lambda execution role. This appears as/Policies/Ndrift withExpectedValue: null.All false-positive filters (including the existing
isAmplifyAuthRoleDenyToAllowChange) are now registered in aFALSE_POSITIVE_FILTERSarray. The detection loop iterates this array instead of using inline if-statements, so adding future filters is a one-line change.Two new filter functions are added in
detect-stack-drift.ts:isAmplifyRestApiDescriptionDrift— exact match on resource type, property path, and null-vs-empty valuesisAmplifyTriggerPolicyDrift— matches resource type,/Policies/\d+path, null expected value, and parses thePolicyDocumentJSON to verify actions via set containment against known Amplify policy patternsExample console output after running
amplify gen2-migration lockon a gen1 app with REST APIs, auth triggers and S3 triggers.Post-fix:
Issue #, if available
lockcommand shows unexpected drift for auth triggers #14635lockcommand shows unexpected drift for s3 storage triggers #14483lockcommand shows unexpected drift for apps that have REST api #14489Description of how you validated changes
yarn testpasses inpackages/amplify-cli.drift-formatter.test.tsstill passes (14/14).Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.