Skip to content

Commit b6efc22

Browse files
committed
Move DescribeEventsCommand call before DeleteChangeSetCommand to fix validation error reporting
1 parent 6393a72 commit b6efc22

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

dist/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

src/deploy.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,7 @@ export async function cleanupChangeSet(
221221
if (changeSetStatus.Status === 'FAILED') {
222222
core.debug('Deleting failed Change Set')
223223

224-
if (!noDeleteFailedChangeSet) {
225-
cfn.send(
226-
new DeleteChangeSetCommand({
227-
ChangeSetName: params.ChangeSetName,
228-
StackName: params.StackName
229-
})
230-
)
231-
}
232-
233-
if (
234-
!failOnEmptyChangeSet &&
235-
knownErrorMessages.some(err =>
236-
changeSetStatus.StatusReason?.includes(err)
237-
)
238-
) {
239-
return stack.StackId
240-
}
241-
242-
// Get detailed failure information for change set creation failures
224+
// Get detailed failure information BEFORE deleting the change set
243225
let failureReason = `Failed to create Change Set: ${changeSetStatus.StatusReason}`
244226

245227
// Only call DescribeEvents for validation failures (ExecutionStatus: UNAVAILABLE, Status: FAILED)
@@ -276,6 +258,24 @@ export async function cleanupChangeSet(
276258
}
277259
}
278260

261+
if (!noDeleteFailedChangeSet) {
262+
cfn.send(
263+
new DeleteChangeSetCommand({
264+
ChangeSetName: params.ChangeSetName,
265+
StackName: params.StackName
266+
})
267+
)
268+
}
269+
270+
if (
271+
!failOnEmptyChangeSet &&
272+
knownErrorMessages.some(err =>
273+
changeSetStatus.StatusReason?.includes(err)
274+
)
275+
) {
276+
return stack.StackId
277+
}
278+
279279
throw new Error(failureReason)
280280
}
281281
}

0 commit comments

Comments
 (0)