Skip to content

Commit 207be27

Browse files
committed
fix: evaluate all nested stacks during GetAtt evaluation
1 parent 25ee8ef commit 207be27

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export class EvaluateCloudFormationTemplate {
387387

388388
if (foundResource.ResourceType == 'AWS::CloudFormation::Stack' && attribute?.startsWith('Outputs.')) {
389389
// need to resolve attributes from another stack's Output section
390-
const dependantStackName = this.nestedStackNames[logicalId]?.nestedStackPhysicalName;
390+
const dependantStackName = this.findNestedStack(logicalId, this.nestedStackNames);
391391
if (!dependantStackName) {
392392
//this is a newly created nested stack and cannot be hotswapped
393393
return undefined;
@@ -406,6 +406,19 @@ export class EvaluateCloudFormationTemplate {
406406
return this.formatResourceAttribute(foundResource, attribute);
407407
}
408408

409+
private findNestedStack(logicalId: string, nestedStackNames: {
410+
[nestedStackLogicalId: string]: NestedStackNames;
411+
}): string | undefined {
412+
for (const [nestedStackLogicalId, { nestedChildStackNames, nestedStackPhysicalName }] of Object.entries(nestedStackNames)) {
413+
if (nestedStackLogicalId === logicalId) {
414+
return nestedStackPhysicalName;
415+
}
416+
const checkInNestedChildStacks = this.findNestedStack(logicalId, nestedChildStackNames);
417+
if (checkInNestedChildStacks) return checkInNestedChildStacks;
418+
}
419+
return undefined;
420+
}
421+
409422
private formatResourceAttribute(resource: AWS.CloudFormation.StackResourceSummary, attribute: string | undefined): string | undefined {
410423
const physicalId = resource.PhysicalResourceId;
411424

0 commit comments

Comments
 (0)