https://pulumi.com logo
Title
s

stocky-father-68249

05/03/2023, 10:33 AM
Hey guys is there any clean way of appending a target group to a
aws.lb.listener
in the
default_actions
attribute? I can't do it while creating the actual listener, because the listener is part of another stack.
c

chilly-application-64311

05/03/2023, 11:24 AM
Hi, you can use the ListenerRule resource for that (https://www.pulumi.com/registry/packages/aws/api-docs/alb/listenerrule/) All you need is to get the ARN of your LoadBalancer. Here are some ideas on how you can do this: • Import the ARN from the stack outputs • Hard-code the ARN in the stack configuration (not recommended if the above works)
s

stocky-father-68249

05/03/2023, 11:56 AM
I have the lb arn and the listener arn exported. Thanks for the starting point @chilly-application-64311
But will the rule work if the tg is not already associated with the listener?
c

chilly-application-64311

05/03/2023, 12:02 PM
It will work. This is actually how you associate a TargetGroup with your Listener. In the
actions
property you specify target groups that the requests should be forwarded to.
s

stocky-father-68249

05/03/2023, 12:04 PM
Got it, hopefully it won't do anything with the default action?
c

chilly-application-64311

05/03/2023, 12:10 PM
No, but keep in mind that other rules that you add will have higher priority.
s

stocky-father-68249

05/03/2023, 12:11 PM
Got it
@chilly-application-64311 Hey thanks a lot again for helping out, worked like a charm, after ironing out a few nuances (seems like stack references from a different stack of the same project doesn't work, worked it out with ssm). Thanks a lot!