While this was probably not a good idea, the fact ...
# general
c
While this was probably not a good idea, the fact that it works is pretty cool 😂 Sets up a GCP Target Pool with the instances from the created GKE Node Pool:
Copy code
const target = new gcp.compute.TargetPool("node-pool-target", {
  sessionAffinity: "CLIENT_IP",
  project,
  region: location,
  instances: defaultNodePool.instanceGroupUrls
    .apply(groups =>
      groups.map(group => {
        const splat = group.split("/");
        const idxZones = splat.indexOf("zones");
        const zone = splat[idxZones + 1];
        const groupId = splat[idxZones + 3];
        return { group: groupId, zone };
      })
    )
    .apply(groups =>
      Promise.all(
        groups.map(group =>
          gcp.compute
            .getInstanceGroup({ project, name: group.group, zone: group.zone })
            .then(r => r.instances)
        )
      ).then(flatten)
    )
});