Skip to content

Commit

Permalink
fix(cli): unable to update stacks in ROLLBACK_COMPLETE
Browse files Browse the repository at this point in the history
The CLI mistakingly determined that a stack in `ROLLBACK_COMPLETE` status is not updatable.

This change cleans up this logic so that a stack update will fail only if the stack is in `_FAILED` status, which is a non-updatable state.

Fixes #8126
  • Loading branch information
Elad Ben-Israel committed Jun 29, 2020
1 parent 991024d commit 0eb752e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions packages/aws-cdk/lib/api/util/cloudformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,8 @@ export async function waitForStack(
if (!stack) { return undefined; }

const status = stack.stackStatus;
if (status.isCreationFailure) {
throw new Error(`The stack named ${stackName} failed creation, it may need to be manually deleted from the AWS console: ${status}`);
} else if (!status.isSuccess) {
throw new Error(`The stack named ${stackName} is in a failed state: ${status}`);
if (status.isFailure) {
throw new Error(`The stack named ${stackName} is in a failed state. You may need to "continue update rollback" or delete it from the AWS console : ${status}`);
} else if (status.isDeleted) {
if (failOnDeletedStack) { throw new Error(`The stack named ${stackName} was deleted`); }
return undefined;
Expand Down
10 changes: 3 additions & 7 deletions packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export class StackStatus {
}

get isFailure(): boolean {
return this.name.endsWith('FAILED');
}

get isRollback(): boolean {
return this.name.indexOf('ROLLBACK') !== -1;
return this.name.endsWith('_FAILED');
}

get isStable(): boolean {
Expand All @@ -37,8 +33,8 @@ export class StackStatus {
return this.name === 'NOT_FOUND';
}

get isSuccess(): boolean {
return !this.isNotFound && !this.isRollback && !this.isFailure;
get isComplete(): boolean {
return this.name.endsWith('_COMPLETE');
}

public toString(): string {
Expand Down

0 comments on commit 0eb752e

Please sign in to comment.