fix(gen2-migration): retain GraphQL model tables during decommission#14662
fix(gen2-migration): retain GraphQL model tables during decommission#14662sai-ray wants to merge 6 commits intogen2-migrationfrom
decommission#14662Conversation
decommission
|
For Also, this would modify our deployed cfn template. The proposed rollback validation is running template drift detection which would conflict here. Just flagging for discussion. |
9pace
left a comment
There was a problem hiding this comment.
Before tryUpdateStack, we should add a changeset validation step similar to what we do in the refactor step.
Right now, setDeletionPolicyRetainOnDynamoTables modifies the template and calls tryUpdateStack directly without verifying that the only changes CloudFormation will apply are DeletionPolicy updates.
for the lock step, we should implement:
1. Before calling tryUpdateStack, create a changeset on the stack
2. Describe the changeset and inspect Changes
3. Validate that every change is a Modify on a AWS::DynamoDB::Table resource, scoped to a deletion policy update that we want
4. If any unexpected changes are present, abort with a clear error
This is the same pattern as in _validations.ts. See:
Fixes: #14524
Description of changes
Running
amplify gen2-migration decommissionafter migrating an Amplify app with api DynamoDB tables, fails withValidations failed: Decommission will delete stateful resources. The refactor step moves auth, storage, and analytics resources to Gen2 but not GraphQL model tables. Gen2 imports those viamodelNameToTableNameMapping. So when decommission tries to delete the Gen1 stack, those tables are still there.Changes
Lock step (
lock.ts):findApiCategoryStacks(): identifies API nested stacks usingstartsWith('api')on logical resource IDs fromDescribeStackResources.setDeletionPolicyRetainOnDynamoTables()for each API stack:GetTemplateDeletionPolicy: RetainonAWS::DynamoDB::TableresourcestryUpdateStackValidation (
_validations.ts):getStatefulResources, when aAWS::DynamoDB::Tableis found in a nested stack, fetches the stack template and checksDeletionPolicy. IfRetain, skips flagging it. Tables withoutRetainare still flagged.By submitting this pull request, I confirm that my contribution is
made under the terms of the Apache 2.0 license.
Issue #, if available
Description of how you validated changes
lockanddecomissioncommands on a sample Gen1 app.Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.