Skip to content

Commit

Permalink
Prepare for the case where PhysicalResourceId is missing (#31654)
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Oct 7, 2024
1 parent efdf9b5 commit a187164
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/aws-cdk/lib/api/util/cloudformation/stack-event-poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,20 @@ export class StackEventPoller {
* On the CREATE_IN_PROGRESS, UPDATE_IN_PROGRESS, DELETE_IN_PROGRESS event of a nested stack, poll the nested stack updates
*/
private trackNestedStack(event: aws.CloudFormation.StackEvent, parentStackLogicalIds: string[]) {
const logicalId = event.LogicalResourceId ?? '';
const logicalId = event.LogicalResourceId;
const physicalResourceId = event.PhysicalResourceId;

// The CREATE_IN_PROGRESS event for a Nested Stack is emitted twice; first without a PhysicalResourceId
// and then with. Ignore this event if we don't have that property yet.
//
// (At this point, I also don't trust that logicalId is always going to be there so validate that as well)
if (!logicalId || !physicalResourceId) {
return;
}

if (!this.nestedStackPollers[logicalId]) {
this.nestedStackPollers[logicalId] = new StackEventPoller(this.cfn, {
stackName: event.PhysicalResourceId ?? '',
stackName: physicalResourceId,
parentStackLogicalIds: parentStackLogicalIds,
startTime: event.Timestamp.valueOf(),
});
Expand Down

0 comments on commit a187164

Please sign in to comment.