https://pulumi.com logo
#general
Title
# general
c

creamy-jelly-91590

05/19/2019, 11:40 AM
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)
    )
});