Skip to content

Commit

Permalink
chore: catch and wrap deployment in progress when deleting the backend (
Browse files Browse the repository at this point in the history
  • Loading branch information
Amplifiyer authored Dec 23, 2024
1 parent abff5a0 commit 642b441
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-maps-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/backend-deployer': patch
---

catch and wrap deployment in progress when deleting the backend
7 changes: 7 additions & 0 deletions packages/backend-deployer/src/cdk_error_mapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,13 @@ npm error enoent`,
errorName: 'CloudformationResourceCircularDependencyError',
expectedDownstreamErrorMessage: undefined,
},
{
errorMessage: `destroy failed Error: Stack [someStackArn] cannot be deleted while in status UPDATE_COMPLETE_CLEANUP_IN_PROGRESS`,
expectedTopLevelErrorMessage:
'Backend failed to be deleted since the previous deployment is still in progress.',
errorName: 'DeleteFailedWhileDeploymentInProgressError',
expectedDownstreamErrorMessage: undefined,
},
];

void describe('invokeCDKCommand', { concurrency: 1 }, () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/backend-deployer/src/cdk_error_mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ export class CdkErrorMapper {
errorName: 'CDKAssetPublishError',
classification: 'ERROR',
},
{
// We capture the parameter name to show relevant error message
errorRegex:
/destroy failed Error: Stack \[(?<stackArn>.*)\] cannot be deleted while in status /,
humanReadableErrorMessage: `Backend failed to be deleted since the previous deployment is still in progress.`,
resolutionMessage: `Wait for the previous deployment for stack {stackArn} to be completed before attempting to delete again.`,
errorName: 'DeleteFailedWhileDeploymentInProgressError',
classification: 'ERROR',
},
// Generic error printed by CDK. Order matters so keep this towards the bottom of this list
{
// Error: .* is printed to stderr during cdk synth
Expand Down Expand Up @@ -554,6 +563,7 @@ export type CDKDeploymentError =
| 'CloudFormationDeletionError'
| 'CloudFormationDeploymentError'
| 'CommonNPMError'
| 'DeleteFailedWhileDeploymentInProgressError'
| 'FilePermissionsError'
| 'MissingDefineBackendError'
| 'MultipleSandboxInstancesError'
Expand Down

0 comments on commit 642b441

Please sign in to comment.