Skip to content

Commit cdc08b5

Browse files
authored
Merge pull request #14137 from aws-amplify/gen2-migrations-execute
fix(migrate-template-gen): return early if output is not Fn:GetAtt or…
2 parents 67fac5b + 5a985f0 commit cdc08b5

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ describe('CFNOutputResolver', () => {
3737
'Fn::GetAtt': ['SNSRole', 'Arn'],
3838
},
3939
},
40+
HostedUIDomain: {
41+
Description: 'HostedUIDomain',
42+
Value: {
43+
'Fn::If': [
44+
'ShouldNotCreateEnvResources',
45+
'HostedUIDomainLogicalId',
46+
{
47+
'Fn::Join': [
48+
'-',
49+
[
50+
{
51+
Ref: 'hostedUIDomainName',
52+
},
53+
{
54+
Ref: 'env',
55+
},
56+
],
57+
],
58+
},
59+
],
60+
},
61+
},
4062
},
4163
Resources: {
4264
MyS3Bucket: {
@@ -182,6 +204,10 @@ describe('CFNOutputResolver', () => {
182204
Description: 'role arn',
183205
Value: 'arn:aws:iam::12345:role/sns12345-dev',
184206
},
207+
HostedUIDomain: {
208+
Description: 'HostedUIDomain',
209+
Value: 'my-hosted-UI-domain',
210+
},
185211
},
186212
Resources: {
187213
MyS3Bucket: {
@@ -321,6 +347,10 @@ describe('CFNOutputResolver', () => {
321347
OutputKey: 'CreatedSNSRole',
322348
OutputValue: 'arn:aws:iam::12345:role/sns12345-dev',
323349
},
350+
{
351+
OutputKey: 'HostedUIDomain',
352+
OutputValue: 'my-hosted-UI-domain',
353+
},
324354
],
325355
),
326356
).toEqual(expectedTemplate);

packages/amplify-migration-template-gen/src/resolvers/cfn-output-resolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CfnOutputResolver {
4040
stackTemplateResourcesString = stackTemplateResourcesString.replaceAll(outputRegexp, `"${stackOutputValue}"`);
4141
} else if (GET_ATT in value && Array.isArray(value[GET_ATT])) {
4242
logicalResourceId = value[GET_ATT][0];
43+
} else {
44+
return;
4345
}
4446
assert(logicalResourceId);
4547

packages/amplify-migration/src/command-handlers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ export async function revertGen2Migration(fromStack: string, toStack: string) {
332332
const usageData = await getUsageDataMetric(envName);
333333
if (success) {
334334
printer.print(format.success(`Moved resources back to Gen1 stack successfully.`));
335+
const movingGen1BackendFiles = ora(`Moving your Gen1 backend files to ${format.highlight(AMPLIFY_DIR)}`).start();
336+
// Move gen1 amplify from .amplify/migration/amplify to amplify
337+
await fs.rm(AMPLIFY_DIR, { force: true, recursive: true });
338+
await fs.rename(`${MIGRATION_DIR}/amplify`, AMPLIFY_DIR);
339+
movingGen1BackendFiles.succeed(`Moved your Gen1 backend files to ${format.highlight(AMPLIFY_DIR)}`);
335340
await usageData.emitSuccess();
336341
} else {
337342
await usageData.emitError(new Error('Failed to run revert command'));

0 commit comments

Comments
 (0)