This message was deleted.
# general
s
This message was deleted.
b
can you share your code?
s
If you're just trying to be DRY, something like this may work. If I have resources with mostly identical config, but differences in ports/sg/etc... I'll create loops like this to avoid recreating the resource over and over.
Copy code
const listenerPorts = [22, 443];
const albListerners: aws.lb.Listener[] = [];

for (
  const range = { value: 0 };
  range.value < listenerPorts.length;
  range.value++
) {
  albListerners.push(
    new aws.lb.Listener(`listener-${range.value}`, {
      loadBalancerArn: pulumi.output(alb).arn,
      port: listenerPorts[range.value],
      protocol: "HTTPS",
      sslPolicy: "ELBSecurityPolicy-TLS-1-2-2017-01",
      certificateArn: pulumi.output(acmCert).arn,
      defaultActions: [
        {
          targetGroupArn: pulumi.output(albTargetGroup).arn,
          type: "forward",
        },
      ],
    })
  );
}
r
That looks interesting, thanks @shy-waiter-84958. Yes, trying to keep it DRY.