diff --git a/.changeset/purple-news-do.md b/.changeset/purple-news-do.md new file mode 100644 index 0000000000..4c64d168bb --- /dev/null +++ b/.changeset/purple-news-do.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/backend-deployer': patch +--- + +Catches most common EPERM error and update to resolution message for stack in failed state diff --git a/packages/backend-deployer/src/cdk_error_mapper.test.ts b/packages/backend-deployer/src/cdk_error_mapper.test.ts index 3850467a35..a4f9d4952b 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.test.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.test.ts @@ -359,6 +359,12 @@ const testErrorMappings = [ errorName: 'FilePermissionsError', expectedDownstreamErrorMessage: `EACCES: permission denied, unlink '.amplify/artifacts/cdk.out/synth.lock'`, }, + { + errorMessage: `EPERM: operation not permitted, rename 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock.6785_1' → 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock'`, + expectedTopLevelErrorMessage: `Not permitted to rename file: 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock.6785_1'`, + errorName: 'FilePermissionsError', + expectedDownstreamErrorMessage: undefined, + }, { errorMessage: `This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is 36.0.0, but found 36.1.1)`, diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index 949a9212f3..5b121ea673 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -184,6 +184,14 @@ export class CdkErrorMapper { errorName: 'FilePermissionsError', classification: 'ERROR', }, + { + errorRegex: + /EPERM: operation not permitted, rename (?(.*)\/synth\.lock\.\S+) → '(.*)\/synth\.lock'/, + humanReadableErrorMessage: 'Not permitted to rename file: {fileName}', + resolutionMessage: `Try running the command again and ensure that only one instance of sandbox is running. If it still doesn't work check the permissions of '.amplify' folder`, + errorName: 'FilePermissionsError', + classification: 'ERROR', + }, { errorRegex: new RegExp( `\\[ERR_MODULE_NOT_FOUND\\]:(.*)${this.multiLineEolRegex}|Error: Cannot find module (.*)` @@ -220,7 +228,7 @@ export class CdkErrorMapper { humanReadableErrorMessage: 'The CloudFormation deletion failed due to {stackName} being in DELETE_FAILED state. Ensure all your resources are able to be deleted', resolutionMessage: - 'The following resource(s) failed to delete: {resources}. Ensure they are in a state where they can be deleted. Find more information in the CloudFormation AWS Console for this stack.', + 'The following resource(s) failed to delete: {resources}. Check the error message for more details and ensure your resources are in a state where they can be deleted. Check the CloudFormation AWS Console for this stack to find additional information.', errorName: 'CloudFormationDeletionError', classification: 'ERROR', },