Skip to content

Conversation

@sai-ray
Copy link

@sai-ray sai-ray commented Oct 24, 2025

Description of changes

This PR implements stateful resource validation to prevent accidental data loss during Gen 1 to Gen 2 migrations for refactor and decommission commands. The implementation adds a stateful-resources.ts file that defines stateful resource types. The validateStatefulResources() method analyzes CloudFormation changesets and throws a DestructiveMigrationError when stateful resources are scheduled for deletion, providing clear messaging about affected resources. The @aws-sdk/client-cloudformation dependency has been added to support changeset analysis.

Issue #, if available

N/A

Description of how you validated changes

Added unit tests covering multiple scenarios:

  • Empty changesets and changesets with no stateful resource deletions
  • Single and multiple stateful resource deletion attempts
  • Mixed operations (add/remove/modify) on both stateful and stateless resources

All tests pass successfully, validating that the implementation correctly allows safe operations (add/modify any resources, remove stateless resources) while blocking destructive operations (remove stateful resources).

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.

@sai-ray sai-ray requested a review from a team as a code owner October 24, 2025 15:23
@sai-ray sai-ray changed the title Sai/stateful resources for gen2 migration feat(gen2-migration): add stateful resource validation for safe migrations Oct 24, 2025
@iliapolo iliapolo merged commit 394cb28 into gen2-migration Oct 28, 2025
4 checks passed
@iliapolo iliapolo deleted the sai/stateful-resources-for-gen2-migration branch October 28, 2025 13:54
iankhou pushed a commit that referenced this pull request Oct 28, 2025
…tions (#14297)

* chore: scaffolding migration

* chore: add gen2 migration stateful resources validations and unit tests

* chore: update gen2 migration validations to use AWS SDK v3

---------

Co-authored-by: Eli Polonsky <epolon@amazon.com>
Co-authored-by: Sai Ray <saisujit@amazon.com>
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.

2 participants