fix(gen2-migration): retain GraphQL model tables during decommission#14662
Conversation
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:
…ommission-dynamoDB-deletion-gen2-migration
@9pace The flow is now:
The validation allows only Modify actions on Also replaced the tryUpdateStack import (removed in #14698) with inline Added 4 tests:
Validated on a deployed app, lock completes successfully with the changeset validation passing. |
|
Still interested in #14662 (comment) |
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 usingextractCategoryon logical resource IDs fromDescribeStackResources.setDeletionPolicyRetainOnDynamoTables()for each API stack: lists its model nested stacks, fetches each template viaGetTemplate, setsDeletionPolicy: RetainonAWS::DynamoDB::Tableresources.AWS::DynamoDB::TableorAWS::IAM::Policy(known side effect), aborts if unexpected changes are found. The changeset is deleted after validation, then the update is applied viaUpdateStackCommand+waitUntilStackUpdateComplete.refactorbreaks for user pool groups #14698) with inline UpdateStackCommand + SDK waiter, matching the Cfn.update() pattern.Validation (
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.