@@ -50330,6 +50330,7 @@ function cleanupChangeSet(cfn, stack, params, failOnEmptyChangeSet, noDeleteFail
5033050330}
5033150331function updateStack(cfn, stack, params, failOnEmptyChangeSet, noExecuteChangeSet, noDeleteFailedChangeSet) {
5033250332 return __awaiter(this, void 0, void 0, function* () {
50333+ var _a, _b, _c, _d;
5033350334 core.debug('Creating CloudFormation Change Set');
5033450335 const createResponse = yield cfn.send(new client_cloudformation_1.CreateChangeSetCommand(params));
5033550336 try {
@@ -50339,7 +50340,7 @@ function updateStack(cfn, stack, params, failOnEmptyChangeSet, noExecuteChangeSe
5033950340 StackName: params.StackName
5034050341 });
5034150342 }
50342- catch (_a ) {
50343+ catch (_e ) {
5034350344 core.debug('Change set creation waiter failed, getting change set info anyway');
5034450345 // Still try to get change set info even if waiter failed
5034550346 const changeSetInfo = yield getChangeSetInfo(cfn, params.ChangeSetName, params.StackName);
@@ -50358,14 +50359,32 @@ function updateStack(cfn, stack, params, failOnEmptyChangeSet, noExecuteChangeSe
5035850359 StackName: params.StackName
5035950360 }));
5036050361 core.debug('Updating CloudFormation stack');
50361- yield waitUntilStackOperationComplete({
50362- client: cfn,
50363- maxWaitTime: 43200,
50364- minDelay: 10,
50365- changeSetId: changeSetInfo.changeSetId
50366- }, {
50367- StackName: params.StackName
50368- });
50362+ try {
50363+ yield waitUntilStackOperationComplete({
50364+ client: cfn,
50365+ maxWaitTime: 43200,
50366+ minDelay: 10,
50367+ changeSetId: changeSetInfo.changeSetId
50368+ }, {
50369+ StackName: params.StackName
50370+ });
50371+ }
50372+ catch (error) {
50373+ // Get execution failure details using OperationId
50374+ const stackResponse = yield cfn.send(new client_cloudformation_1.DescribeStacksCommand({ StackName: params.StackName }));
50375+ const executionOp = (_c = (_b = (_a = stackResponse.Stacks) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.LastOperations) === null || _c === void 0 ? void 0 : _c.find(op => op.OperationType === 'UPDATE_STACK' || op.OperationType === 'CREATE_STACK');
50376+ if (executionOp === null || executionOp === void 0 ? void 0 : executionOp.OperationId) {
50377+ const eventsResponse = yield cfn.send(new client_cloudformation_1.DescribeEventsCommand({
50378+ OperationId: executionOp.OperationId,
50379+ Filters: { FailedEvents: true }
50380+ }));
50381+ if ((_d = eventsResponse.OperationEvents) === null || _d === void 0 ? void 0 : _d.length) {
50382+ const failureEvent = eventsResponse.OperationEvents[0];
50383+ throw new Error(`Stack execution failed: ${failureEvent.ResourceStatusReason || failureEvent.ResourceStatus}`);
50384+ }
50385+ }
50386+ throw error;
50387+ }
5036950388 return { stackId: stack.StackId };
5037050389 });
5037150390}
0 commit comments