diff --git a/packages/amplify-cli/src/__tests__/test-aborting.test.ts b/packages/amplify-cli/src/__tests__/test-aborting.test.ts index eff9ff93f69..6fac43283a1 100644 --- a/packages/amplify-cli/src/__tests__/test-aborting.test.ts +++ b/packages/amplify-cli/src/__tests__/test-aborting.test.ts @@ -74,7 +74,6 @@ describe('test SIGINT with execute', () => { mockContext.amplify = jest.genMockFromModule('../domain/amplify-toolkit'); jest.setMock('../context-manager', { constructContext: jest.fn().mockReturnValue(mockContext), - persistContext: jest.fn(), attachUsageData: jest.fn(), }); diff --git a/packages/amplify-cli/src/context-manager.ts b/packages/amplify-cli/src/context-manager.ts index dbd503612a9..fdd99819106 100644 --- a/packages/amplify-cli/src/context-manager.ts +++ b/packages/amplify-cli/src/context-manager.ts @@ -45,7 +45,3 @@ const getProjectSettings = (): ProjectSettings => { return projectSettings; }; -export function persistContext(context: Context): void { - // write to the backend and current backend - // and get the frontend plugin to write to the config files. -} diff --git a/packages/amplify-cli/src/index.ts b/packages/amplify-cli/src/index.ts index 4969b725baf..3f13b432cf9 100644 --- a/packages/amplify-cli/src/index.ts +++ b/packages/amplify-cli/src/index.ts @@ -17,7 +17,7 @@ import * as fs from 'fs-extra'; import * as path from 'path'; import { logInput } from './conditional-local-logging-init'; import { print } from './context-extensions'; -import { attachUsageData, constructContext, persistContext } from './context-manager'; +import { attachUsageData, constructContext } from './context-manager'; import { displayBannerMessages } from './display-banner-messages'; import { constants } from './domain/constants'; import { Context } from './domain/context'; @@ -156,8 +156,6 @@ export async function run() { context.usageData.emitSuccess(); } - persistContext(context); - // no command supplied defaults to help, give update notification at end of execution if (input.command === 'help') { // Checks for available update, defaults to a 1 day interval for notification @@ -290,8 +288,6 @@ export async function execute(input: Input): Promise { context.usageData.emitSuccess(); } - persistContext(context); - return exitCode; } catch (e) { // ToDo: add logging to the core, and log execution errors using the unified core logging. diff --git a/packages/amplify-provider-awscloudformation/src/aws-utils/aws-cfn.js b/packages/amplify-provider-awscloudformation/src/aws-utils/aws-cfn.js index 112e75940f1..571683df4b3 100644 --- a/packages/amplify-provider-awscloudformation/src/aws-utils/aws-cfn.js +++ b/packages/amplify-provider-awscloudformation/src/aws-utils/aws-cfn.js @@ -286,15 +286,16 @@ class CloudFormation { const cfnCompleteStatus = 'stackUpdateComplete'; if (updateErr) { - console.error('Error updating cloudformation stack'); - reject(updateErr); + if (self.pollForEvents) { + clearInterval(self.pollForEvents); + } + return reject(updateErr); } cfnModel.waitFor(cfnCompleteStatus, cfnStackCheckParams, completeErr => { if (self.pollForEvents) { clearInterval(self.pollForEvents); } if (completeErr) { - console.error('Error updating cloudformation stack'); this.collectStackErrors(cfnParentStackParams.StackName).then(() => reject(completeErr)); } else { return self.updateamplifyMetaFileWithStackOutputs(stackName).then(() => resolve()); @@ -463,7 +464,7 @@ class CloudFormation { cfnModel.deleteStack(cfnStackParams, deleteErr => { if (deleteErr) { console.log(`Error deleting stack ${stackName}`); - reject(deleteErr); + return reject(deleteErr); } cfnModel.waitFor(cfnDeleteStatus, cfnStackParams, completeErr => { if (err) { diff --git a/packages/amplify-provider-awscloudformation/src/push-resources.ts b/packages/amplify-provider-awscloudformation/src/push-resources.ts index f0396e9876b..0417cfb8aef 100644 --- a/packages/amplify-provider-awscloudformation/src/push-resources.ts +++ b/packages/amplify-provider-awscloudformation/src/push-resources.ts @@ -263,7 +263,17 @@ export async function run(context: $TSContext, resourceDefinition: $TSObject) { const nestedStack = await formNestedStack(context, context.amplify.getProjectDetails()); - await updateCloudFormationNestedStack(context, nestedStack, resourcesToBeCreated, resourcesToBeUpdated); + try { + await updateCloudFormationNestedStack(context, nestedStack, resourcesToBeCreated, resourcesToBeUpdated); + } catch (err) { + if (err?.name === 'ValidationError' && err?.message === 'No updates are to be performed.') { + return; + } else { + throw err; + } + } finally { + spinner.stop(); + } } }