in packages/cdk-graph/src/core/utils.ts [169:226]
traverse(from).forEach(function (this: traverse.TraverseContext) {
switch (this.key) {
case ReferenceTypeEnum.ATTRIBUTE: {
const [logicalId, attribute] = this.node as [string, string];
references.push({
source,
referenceType: ReferenceTypeEnum.ATTRIBUTE,
target: logicalId,
value: attribute,
});
this.block();
break;
}
case ReferenceTypeEnum.REF: {
if (typeof this.node === "string") {
if (!IGNORE_REF_PATTERN.test(this.node)) {
references.push({
source,
referenceType: ReferenceTypeEnum.REF,
target: this.node as string,
});
}
} else {
console.warn(`Found non-string "Ref"`, this.node);
}
this.block();
break;
}
case ReferenceTypeEnum.IMPORT: {
// "Fn::ImportValue": "Ada:ExportsOutputFnGetAttCommonStackA8F9EE77OutputsAdaCommonStackCounterTable5D6ADA16ArnED1AF27F"
// "Fn::ImportValue": "Stage-Ada:ExportsOutputFnGetAttCommonStackA8F9EE77OutputsAdaCommonStackCounterTable5D6ADA16ArnED1AF27F"
references.push({
source,
referenceType: ReferenceTypeEnum.IMPORT,
// NB: remove stage - separator
target: (this.node as string).replace("-", ""),
});
this.block();
break;
}
case "Fn::Join": {
if (
Array.isArray(this.node) &&
this.node.flatMap(String).join("").startsWith("arn:")
) {
const potentialImportArn = {
"Fn::Join": this.node,
};
references.push({
source,
referenceType: ReferenceTypeEnum.IMPORT_ARN,
target: tokenizeImportArn(potentialImportArn),
});
}
break;
}
}
});