diff --git a/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.test.ts b/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.test.ts index 70c10a52acd..a1aebe970ed 100644 --- a/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.test.ts +++ b/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.test.ts @@ -37,6 +37,28 @@ describe('CFNOutputResolver', () => { 'Fn::GetAtt': ['SNSRole', 'Arn'], }, }, + HostedUIDomain: { + Description: 'HostedUIDomain', + Value: { + 'Fn::If': [ + 'ShouldNotCreateEnvResources', + 'HostedUIDomainLogicalId', + { + 'Fn::Join': [ + '-', + [ + { + Ref: 'hostedUIDomainName', + }, + { + Ref: 'env', + }, + ], + ], + }, + ], + }, + }, }, Resources: { MyS3Bucket: { @@ -182,6 +204,10 @@ describe('CFNOutputResolver', () => { Description: 'role arn', Value: 'arn:aws:iam::12345:role/sns12345-dev', }, + HostedUIDomain: { + Description: 'HostedUIDomain', + Value: 'my-hosted-UI-domain', + }, }, Resources: { MyS3Bucket: { @@ -321,6 +347,10 @@ describe('CFNOutputResolver', () => { OutputKey: 'CreatedSNSRole', OutputValue: 'arn:aws:iam::12345:role/sns12345-dev', }, + { + OutputKey: 'HostedUIDomain', + OutputValue: 'my-hosted-UI-domain', + }, ], ), ).toEqual(expectedTemplate); diff --git a/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.ts b/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.ts index 5f100f16629..ce83a711a93 100644 --- a/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.ts +++ b/packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.ts @@ -40,6 +40,8 @@ class CfnOutputResolver { stackTemplateResourcesString = stackTemplateResourcesString.replaceAll(outputRegexp, `"${stackOutputValue}"`); } else if (GET_ATT in value && Array.isArray(value[GET_ATT])) { logicalResourceId = value[GET_ATT][0]; + } else { + return; } assert(logicalResourceId); diff --git a/packages/amplify-migration/src/command-handlers.ts b/packages/amplify-migration/src/command-handlers.ts index 33b8c49818c..0615584a789 100644 --- a/packages/amplify-migration/src/command-handlers.ts +++ b/packages/amplify-migration/src/command-handlers.ts @@ -332,6 +332,11 @@ export async function revertGen2Migration(fromStack: string, toStack: string) { const usageData = await getUsageDataMetric(envName); if (success) { printer.print(format.success(`Moved resources back to Gen1 stack successfully.`)); + const movingGen1BackendFiles = ora(`Moving your Gen1 backend files to ${format.highlight(AMPLIFY_DIR)}`).start(); + // Move gen1 amplify from .amplify/migration/amplify to amplify + await fs.rm(AMPLIFY_DIR, { force: true, recursive: true }); + await fs.rename(`${MIGRATION_DIR}/amplify`, AMPLIFY_DIR); + movingGen1BackendFiles.succeed(`Moved your Gen1 backend files to ${format.highlight(AMPLIFY_DIR)}`); await usageData.emitSuccess(); } else { await usageData.emitError(new Error('Failed to run revert command'));