diff --git a/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts b/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts index f52f7bed46..ed340d7099 100644 --- a/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts +++ b/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts @@ -63,54 +63,33 @@ describe('MigrationReadMeGenerator', () => { `### STEP 1: CREATE AND EXECUTE CLOUDFORMATION STACK REFACTOR FOR auth CATEGORY This step will move the Gen1 auth resources to Gen2 stack. -1.a) Upload the source and destination templates to S3 +1.a) Create stack refactor \`\`\` -export BUCKET_NAME=<> -\`\`\` - -\`\`\` -aws s3 cp test/step3-sourceTemplate.json s3://$BUCKET_NAME -\`\`\` - -\`\`\` -aws s3 cp test/step3-destinationTemplate.json s3://$BUCKET_NAME -\`\`\` - -1.b) Create stack refactor -\`\`\` -aws cloudformation create-stack-refactor --stack-definitions StackName=amplify-testauth-dev-12345-auth-ABCDE,TemplateURL=s3://$BUCKET_NAME/step3-sourceTemplate.json StackName=amplify-mygen2app-test-sandbox-12345-auth-ABCDE,TemplateURL=s3://$BUCKET_NAME/step3-destinationTemplate.json --resource-mappings '[{\"Source\":{\"StackName\":\"amplify-testauth-dev-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen1FooUserPool\"},\"Destination\":{\"StackName\":\"amplify-mygen2app-test-sandbox-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen2FooUserPool\"}}]' +aws cloudformation create-stack-refactor --stack-definitions StackName=amplify-testauth-dev-12345-auth-ABCDE,TemplateBody@=file://test/step3-sourceTemplate.json StackName=amplify-mygen2app-test-sandbox-12345-auth-ABCDE,TemplateBody@=file://test/step3-destinationTemplate.json --resource-mappings '[{\"Source\":{\"StackName\":\"amplify-testauth-dev-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen1FooUserPool\"},\"Destination\":{\"StackName\":\"amplify-mygen2app-test-sandbox-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen2FooUserPool\"}}]' \`\`\` \`\`\` export STACK_REFACTOR_ID=<> \`\`\` -1.c) Describe stack refactor to check for creation status +1.b) Describe stack refactor to check for creation status \`\`\` aws cloudformation describe-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` -1.d) Execute stack refactor +1.c) Execute stack refactor \`\`\` aws cloudformation execute-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` -1.e) Describe stack refactor to check for execution status +1.d) Describe stack refactor to check for execution status \`\`\` aws cloudformation describe-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` #### Rollback step for refactor: \`\`\` -aws s3 cp test/step3-sourceTemplate-rollback.json s3://$BUCKET_NAME -\`\`\` - -\`\`\` -aws s3 cp test/step3-destinationTemplate-rollback.json s3://$BUCKET_NAME -\`\`\` - -\`\`\` - aws cloudformation create-stack-refactor --stack-definitions StackName=amplify-testauth-dev-12345-auth-ABCDE,TemplateURL=s3://$BUCKET_NAME/step3-sourceTemplate-rollback.json StackName=amplify-mygen2app-test-sandbox-12345-auth-ABCDE,TemplateURL=s3://$BUCKET_NAME/step3-destinationTemplate-rollback.json --resource-mappings '[{\"Source\":{\"StackName\":\"amplify-mygen2app-test-sandbox-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen2FooUserPool\"},\"Destination\":{\"StackName\":\"amplify-testauth-dev-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen1FooUserPool\"}}]' + aws cloudformation create-stack-refactor --stack-definitions StackName=amplify-testauth-dev-12345-auth-ABCDE,TemplateBody@=file://test/step3-sourceTemplate-rollback.json StackName=amplify-mygen2app-test-sandbox-12345-auth-ABCDE,TemplateBody@=file://test/step3-destinationTemplate-rollback.json --resource-mappings '[{\"Source\":{\"StackName\":\"amplify-mygen2app-test-sandbox-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen2FooUserPool\"},\"Destination\":{\"StackName\":\"amplify-testauth-dev-12345-auth-ABCDE\",\"LogicalResourceId\":\"Gen1FooUserPool\"}}]' \`\`\` \`\`\` diff --git a/packages/amplify-migration-template-gen/src/migration-readme-generator.ts b/packages/amplify-migration-template-gen/src/migration-readme-generator.ts index 3e0f341427..6d2ebe7706 100644 --- a/packages/amplify-migration-template-gen/src/migration-readme-generator.ts +++ b/packages/amplify-migration-template-gen/src/migration-readme-generator.ts @@ -33,6 +33,8 @@ class MigrationReadmeGenerator { * @param sourceTemplate * @param destinationTemplate * @param logicalIdMapping + * @param oldSourceTemplate + * @param oldDestinationTemplate */ async renderStep1( sourceTemplate: CFNTemplate, @@ -80,24 +82,11 @@ class MigrationReadmeGenerator { `### STEP 1: CREATE AND EXECUTE CLOUDFORMATION STACK REFACTOR FOR ${this.category} CATEGORY This step will move the Gen1 ${this.category} resources to Gen2 stack. -1.a) Upload the source and destination templates to S3 -\`\`\` -export BUCKET_NAME=<> -\`\`\` - -\`\`\` -aws s3 cp ${step1SourceTemplateFileNamePath} s3://$BUCKET_NAME -\`\`\` - -\`\`\` -aws s3 cp ${step1DestinationTemplateFileNamePath} s3://$BUCKET_NAME -\`\`\` - -1.b) Create stack refactor +1.a) Create stack refactor \`\`\` aws cloudformation create-stack-refactor \ - --stack-definitions StackName=${this.gen1CategoryStackName},TemplateURL=s3://$BUCKET_NAME/${sourceTemplateFileName} \ - StackName=${this.gen2CategoryStackName},TemplateURL=s3://$BUCKET_NAME/${destinationTemplateFileName} \ + --stack-definitions StackName=${this.gen1CategoryStackName},TemplateBody@=file://${step1SourceTemplateFileNamePath} \ + StackName=${this.gen2CategoryStackName},TemplateBody@=file://${step1DestinationTemplateFileNamePath} \ --resource-mappings \ '${JSON.stringify(resourceMappings)}' \`\`\` @@ -106,34 +95,26 @@ aws cloudformation create-stack-refactor \ export STACK_REFACTOR_ID=<> \`\`\` -1.c) Describe stack refactor to check for creation status +1.b) Describe stack refactor to check for creation status \`\`\` aws cloudformation describe-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` -1.d) Execute stack refactor +1.c) Execute stack refactor \`\`\` aws cloudformation execute-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` -1.e) Describe stack refactor to check for execution status +1.d) Describe stack refactor to check for execution status \`\`\` aws cloudformation describe-stack-refactor --stack-refactor-id $STACK_REFACTOR_ID \`\`\` #### Rollback step for refactor: -\`\`\` -aws s3 cp ${step1RollbackSourceTemplateFileNamePath} s3://$BUCKET_NAME -\`\`\` - -\`\`\` -aws s3 cp ${step1RollbackDestinationTemplateFileNamePath} s3://$BUCKET_NAME -\`\`\` - \`\`\` aws cloudformation create-stack-refactor \ - --stack-definitions StackName=${this.gen1CategoryStackName},TemplateURL=s3://$BUCKET_NAME/${rollbackSourceTemplateFileName} \ - StackName=${this.gen2CategoryStackName},TemplateURL=s3://$BUCKET_NAME/${rollbackDestinationTemplateFileName} \ + --stack-definitions StackName=${this.gen1CategoryStackName},TemplateBody@=file://${step1RollbackSourceTemplateFileNamePath} \ + StackName=${this.gen2CategoryStackName},TemplateBody@=file://${step1RollbackDestinationTemplateFileNamePath} \ --resource-mappings \ '${JSON.stringify(rollbackResourceMappings)}' \`\`\`