Skip to content

fix(cli): add rollback validation to lock step (template drift approach)#14701

Open
9pace wants to merge 3 commits intogen2-migrationfrom
14570-template-drift
Open

fix(cli): add rollback validation to lock step (template drift approach)#14701
9pace wants to merge 3 commits intogen2-migrationfrom
14570-template-drift

Conversation

@9pace
Copy link
Copy Markdown

@9pace 9pace commented Mar 24, 2026

Summary

  • Implements rollbackValidate() in the lock migration step to detect post-refactor state before allowing rollback
  • Adds validateTemplateDrift() to AmplifyGen2MigrationValidations — runs Phase 2 (template drift) only, using CloudFormation change sets to compare deployed templates against the S3-cached baseline
  • Rollback validation now checks: deployment status, lock status, and template drift (in that order)

Closes #14570

Changes

  • _validations.ts: Added validateTemplateDrift() method that syncs cloud backend from S3, then runs detectTemplateDrift() to compare templates via change sets
  • lock.ts: Implemented rollbackValidate() calling validateDeploymentStatus(), validateLockStatus(), and validateTemplateDrift()
  • lock.test.ts: 5 unit tests for rollbackValidate() — happy path, error propagation for each validation
  • _validations-template-drift.test.ts: 6 unit tests for validateTemplateDrift() — no drift, drift detected, S3 sync failure, skipped detection scenarios

Test plan

  • lock.test.ts — 5 tests pass (rollbackValidate calls all validations, error propagation)
  • _validations-template-drift.test.ts — 6 tests pass (template drift detection scenarios)
  • All 11 tests pass locally with npx jest --no-coverage

@9pace 9pace requested a review from a team as a code owner March 24, 2026 16:41
9pace added 3 commits March 26, 2026 15:45
Remove unnecessary Printer adapter that wrapped this.logger and the
redundant `import type { Printer }`. The file already imports the
`printer` singleton from @aws-amplify/amplify-prompts, which is the
correct type expected by detectTemplateDrift() and CloudFormationService.
@9pace 9pace force-pushed the 14570-template-drift branch from 771bba1 to c6424a3 Compare March 26, 2026 15:47
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