function _resolveResourceLikeDataImage()

in packages/cdk-graph-plugin-diagram/src/internal/utils/resource-images.ts [126:170]


function _resolveResourceLikeDataImage(
  node: Graph.CfnResourceNode | Graph.ResourceNode,
  theme?: aws_arch.Themes
): string | undefined {
  const cfnResourceType = node.cfnType;

  if (
    cfnResourceType === aws_arch.CfnSpec.ServiceResourceDictionary.EC2.Instance
  ) {
    const instanceType = node.getCfnProp("instanceType") as string | undefined;
    if (instanceType) {
      try {
        return AwsArchitecture.getInstanceTypeIcon(
          instanceType.toLowerCase().split(".")[0] as any,
          "svg",
          theme
        );
      } catch {}
    }
  }

  if (
    cfnResourceType ===
    aws_arch.CfnSpec.ServiceResourceDictionary.RDS.DBInstance
  ) {
    let engine = node.getCfnProp("engine") as string | undefined;
    if (engine) {
      engine = engine.toLowerCase().split("-")[0] as any;
      // Resolve postgresql variant
      if (engine === "postgres") {
        engine = "postgresql";
      }
      try {
        // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbinstance.html#cfn-rds-dbinstance-engine
        return AwsArchitecture.getRdsInstanceTypeIcon(
          engine as any,
          "svg",
          theme
        );
      } catch {}
    }
  }

  return undefined;
}