Skip to content

Commit e8f89ad

Browse files
committed
Only call DescribeEventsCommand for validation failures (ExecutionStatus: UNAVAILABLE, Status: FAILED)
1 parent 41d93b6 commit e8f89ad

File tree

2 files changed

+51
-46
lines changed

2 files changed

+51
-46
lines changed

dist/index.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50305,25 +50305,27 @@ function cleanupChangeSet(cfn, stack, params, failOnEmptyChangeSet, noDeleteFail
5030550305
}
5030650306
// Get detailed failure information for change set creation failures
5030750307
let failureReason = `Failed to create Change Set: ${changeSetStatus.StatusReason}`;
50308-
const eventChangeSetId = changeSetId || changeSetStatus.ChangeSetId;
50309-
if (eventChangeSetId) {
50310-
try {
50311-
core.info(`Attempting to get change set failure details for: ${eventChangeSetId}`);
50312-
const events = yield cfn.send(new client_cloudformation_1.DescribeEventsCommand({
50313-
ChangeSetName: eventChangeSetId,
50314-
Filters: { FailedEvents: true }
50315-
}));
50316-
core.info(`Retrieved ${((_a = events.OperationEvents) === null || _a === void 0 ? void 0 : _a.length) || 0} failed events for change set`);
50317-
const failedEvents = (_b = events.OperationEvents) === null || _b === void 0 ? void 0 : _b.filter(event => event.ResourceStatusReason);
50318-
if (failedEvents && failedEvents.length > 0) {
50319-
const reasons = failedEvents
50320-
.map(event => `${event.LogicalResourceId}: ${event.ResourceStatusReason}`)
50321-
.join('; ');
50322-
failureReason += `. Failed resources: ${reasons}`;
50308+
// Only call DescribeEvents for validation failures (ExecutionStatus: UNAVAILABLE, Status: FAILED)
50309+
if (changeSetStatus.ExecutionStatus === 'UNAVAILABLE' && changeSetStatus.Status === 'FAILED') {
50310+
const eventChangeSetId = changeSetId || changeSetStatus.ChangeSetId;
50311+
if (eventChangeSetId) {
50312+
try {
50313+
core.info(`Attempting to get validation failure details for: ${eventChangeSetId}`);
50314+
const events = yield cfn.send(new client_cloudformation_1.DescribeEventsCommand({
50315+
ChangeSetName: eventChangeSetId
50316+
}));
50317+
core.info(`Retrieved ${((_a = events.OperationEvents) === null || _a === void 0 ? void 0 : _a.length) || 0} events for change set`);
50318+
const validationEvents = (_b = events.OperationEvents) === null || _b === void 0 ? void 0 : _b.filter(event => event.EventType === 'VALIDATION_ERROR');
50319+
if (validationEvents && validationEvents.length > 0) {
50320+
const reasons = validationEvents
50321+
.map(event => `${event.ValidationPath}: ${event.ValidationStatusReason}`)
50322+
.join('; ');
50323+
failureReason += `. Validation errors: ${reasons}`;
50324+
}
50325+
}
50326+
catch (error) {
50327+
core.info(`Failed to get validation event details: ${error}`);
5032350328
}
50324-
}
50325-
catch (error) {
50326-
core.info(`Failed to get change set event details: ${error}`);
5032750329
}
5032850330
}
5032950331
throw new Error(failureReason);

src/deploy.ts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -250,35 +250,38 @@ export async function cleanupChangeSet(
250250

251251
// Get detailed failure information for change set creation failures
252252
let failureReason = `Failed to create Change Set: ${changeSetStatus.StatusReason}`
253-
const eventChangeSetId = changeSetId || changeSetStatus.ChangeSetId
254-
if (eventChangeSetId) {
255-
try {
256-
core.info(
257-
`Attempting to get change set failure details for: ${eventChangeSetId}`
258-
)
259-
const events = await cfn.send(
260-
new DescribeEventsCommand({
261-
ChangeSetName: eventChangeSetId,
262-
Filters: { FailedEvents: true }
263-
})
264-
)
265-
core.info(
266-
`Retrieved ${events.OperationEvents?.length || 0} failed events for change set`
267-
)
268-
const failedEvents = events.OperationEvents?.filter(
269-
event => event.ResourceStatusReason
270-
)
271-
if (failedEvents && failedEvents.length > 0) {
272-
const reasons = failedEvents
273-
.map(
274-
event =>
275-
`${event.LogicalResourceId}: ${event.ResourceStatusReason}`
276-
)
277-
.join('; ')
278-
failureReason += `. Failed resources: ${reasons}`
253+
254+
// Only call DescribeEvents for validation failures (ExecutionStatus: UNAVAILABLE, Status: FAILED)
255+
if (changeSetStatus.ExecutionStatus === 'UNAVAILABLE' && changeSetStatus.Status === 'FAILED') {
256+
const eventChangeSetId = changeSetId || changeSetStatus.ChangeSetId
257+
if (eventChangeSetId) {
258+
try {
259+
core.info(
260+
`Attempting to get validation failure details for: ${eventChangeSetId}`
261+
)
262+
const events = await cfn.send(
263+
new DescribeEventsCommand({
264+
ChangeSetName: eventChangeSetId
265+
})
266+
)
267+
core.info(
268+
`Retrieved ${events.OperationEvents?.length || 0} events for change set`
269+
)
270+
const validationEvents = events.OperationEvents?.filter(
271+
event => event.EventType === 'VALIDATION_ERROR'
272+
)
273+
if (validationEvents && validationEvents.length > 0) {
274+
const reasons = validationEvents
275+
.map(
276+
event =>
277+
`${event.ValidationPath}: ${event.ValidationStatusReason}`
278+
)
279+
.join('; ')
280+
failureReason += `. Validation errors: ${reasons}`
281+
}
282+
} catch (error) {
283+
core.info(`Failed to get validation event details: ${error}`)
279284
}
280-
} catch (error) {
281-
core.info(`Failed to get change set event details: ${error}`)
282285
}
283286
}
284287

0 commit comments

Comments
 (0)