Skip to content

Commit d332c51

Browse files
ShadowCat567Vieltojarvi
andauthored
Catch "stack is in failed state, you may need to delete it from AWS Console" (DELETE_FAILED) (#2265)
* delete stack regex * test for cloud deletion error * added changeset * making some adjustments * added stack name to error message * update resolution message with failed resources --------- Co-authored-by: Vieltojarvi <[email protected]>
1 parent a6fa42e commit d332c51

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

.changeset/chatty-goats-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
map a form of deletion/destroy failed error

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,13 @@ npm error enoent`,
575575
errorName: 'CommonNPMError',
576576
expectedDownstreamErrorMessage: undefined,
577577
},
578+
{
579+
errorMessage: `[31m: destroy failed Error: The stack named amplify-some-stack is in a failed state. You may need to delete it from the AWS console : DELETE_FAILED (The following resource(s) failed to delete: [resource1, resource2]. )`,
580+
expectedTopLevelErrorMessage:
581+
'The CloudFormation deletion failed due to amplify-some-stack being in DELETE_FAILED state. Ensure all your resources are able to be deleted',
582+
errorName: 'CloudFormationDeletionError',
583+
expectedDownstreamErrorMessage: undefined,
584+
},
578585
];
579586

580587
void describe('invokeCDKCommand', { concurrency: 1 }, () => {

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ export class CdkErrorMapper {
211211
errorName: 'GetLambdaLayerVersionError',
212212
classification: 'ERROR',
213213
},
214+
{
215+
//This has some overlap with "User:__ is not authorized to perform:__ on resource: __" - some resources cannot be deleted due to lack of permissions
216+
errorRegex:
217+
/The stack named (?<stackName>.*) is in a failed state. You may need to delete it from the AWS console : DELETE_FAILED \(The following resource\(s\) failed to delete: (?<resources>.*). \)/,
218+
humanReadableErrorMessage:
219+
'The CloudFormation deletion failed due to {stackName} being in DELETE_FAILED state. Ensure all your resources are able to be deleted',
220+
resolutionMessage:
221+
'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.',
222+
errorName: 'CloudFormationDeletionError',
223+
classification: 'ERROR',
224+
},
214225
{
215226
errorRegex:
216227
/User:(.*) is not authorized to perform:(.*) on resource:(?<resource>.*) because no identity-based policy allows the (?<action>.*) action/,
@@ -439,6 +450,7 @@ export type CDKDeploymentError =
439450
| 'CDKResolveAWSAccountError'
440451
| 'CDKVersionMismatchError'
441452
| 'CFNUpdateNotSupportedError'
453+
| 'CloudFormationDeletionError'
442454
| 'CloudFormationDeploymentError'
443455
| 'CommonNPMError'
444456
| 'FilePermissionsError'

0 commit comments

Comments
 (0)