I want to associate each of my vpcs external subne...
# general
b
I want to associate each of my vpcs external subnets with a nat gateway and make available a map of the subnet ids to gateways for use bny other components.
Copy code
vpc.publicSubnetIds.reduce((gateways, id) => {
      gateways[pulumi.interpolate`${id}`] = vpc.addNatGateway(
        `${config.release.name}-${name}-${id}-gateway`,
        { subnet: id },
        { parent: vpc }
      );
    }, {});
Doesn’t work as output can’t be a key … any guidence
c
Try this:
Copy code
vpc.publicSubnetIds.apply(ids => {
  ids.forEach(id => {
     gateways[id] = vpc.addNatGateway(
        `${config.release.name}-${name}-${id}-gateway`,
        { subnet: id },
        { parent: vpc }
      );
  });
});
b
unfortunately subnetids is an array of output string not a output of string array
I need to flip the onion, but my ts foo is not that strong
c
Ah I see, how about using
pulumi.all()
?
Copy code
pulumi.all(vpc.publicSubnetIds).apply((ids) => {
  ids.forEach(id => {
     gateways[id] = vpc.addNatGateway(
        `${config.release.name}-${name}-${id}-gateway`,
        { subnet: id },
        { parent: vpc }
      );
  });
});
Did you get this working?