@@ -50289,17 +50289,7 @@ function cleanupChangeSet(cfn, stack, params, failOnEmptyChangeSet, noDeleteFail
5028950289 }));
5029050290 if (changeSetStatus.Status === 'FAILED') {
5029150291 core.debug('Deleting failed Change Set');
50292- if (!noDeleteFailedChangeSet) {
50293- cfn.send(new client_cloudformation_1.DeleteChangeSetCommand({
50294- ChangeSetName: params.ChangeSetName,
50295- StackName: params.StackName
50296- }));
50297- }
50298- if (!failOnEmptyChangeSet &&
50299- knownErrorMessages.some(err => { var _a; return (_a = changeSetStatus.StatusReason) === null || _a === void 0 ? void 0 : _a.includes(err); })) {
50300- return stack.StackId;
50301- }
50302- // Get detailed failure information for change set creation failures
50292+ // Get detailed failure information BEFORE deleting the change set
5030350293 let failureReason = `Failed to create Change Set: ${changeSetStatus.StatusReason}`;
5030450294 // Only call DescribeEvents for validation failures (ExecutionStatus: UNAVAILABLE, Status: FAILED)
5030550295 if (changeSetStatus.ExecutionStatus === 'UNAVAILABLE' && changeSetStatus.Status === 'FAILED') {
@@ -50324,6 +50314,16 @@ function cleanupChangeSet(cfn, stack, params, failOnEmptyChangeSet, noDeleteFail
5032450314 }
5032550315 }
5032650316 }
50317+ if (!noDeleteFailedChangeSet) {
50318+ cfn.send(new client_cloudformation_1.DeleteChangeSetCommand({
50319+ ChangeSetName: params.ChangeSetName,
50320+ StackName: params.StackName
50321+ }));
50322+ }
50323+ if (!failOnEmptyChangeSet &&
50324+ knownErrorMessages.some(err => { var _a; return (_a = changeSetStatus.StatusReason) === null || _a === void 0 ? void 0 : _a.includes(err); })) {
50325+ return stack.StackId;
50326+ }
5032750327 throw new Error(failureReason);
5032850328 }
5032950329 });
0 commit comments