sparse-intern-71089
04/22/2021, 1:10 PMwitty-candle-66007
04/22/2021, 1:29 PMelbName is an output property of another resource and you want to use it in the getLoadBalancer call?bumpy-laptop-30846
04/22/2021, 1:30 PMwitty-candle-66007
04/22/2021, 1:30 PM.apply() is your friend:
https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#apply
So it’ll be something like
const elb = otherResource.elbName.apply(elbName => aws.elb.getLoadBalancer({name: elbName})bumpy-laptop-30846
04/22/2021, 1:31 PMbumpy-laptop-30846
04/22/2021, 1:32 PMapply doesn’t run. For example, it won’t run during a preview, when resource output values may be unknown. Therefore, you should avoid side-effects within the callbacks. For this reason, you should not allocate new resources inside of your callbacks either, as it could lead to pulumi preview being wrong.witty-candle-66007
04/22/2021, 1:54 PMget in this block it shouldn’t matter.
That said, what is the other resource from which you are getting the elbName. I’m wondering why you need to do the getLoadBalancer in this use-case.bumpy-laptop-30846
04/22/2021, 2:01 PMwitty-candle-66007
04/22/2021, 2:05 PMget function it should be fine to use the .apply() logic in this case.
Is it actually causing issues for your deployment?bumpy-laptop-30846
04/22/2021, 2:12 PMaws.route53.getZone( { name: 'xxxx' } )
returns a promise rather than a pulumi output.
is it ok to use ‘then’ to get a value as with ‘apply’ in this case?witty-candle-66007
04/22/2021, 2:17 PMbumpy-laptop-30846
04/22/2021, 2:26 PMlittle-cartoon-10569
04/22/2021, 8:29 PMconst elb = aws.elb.getLoadBalancer( { name: elbName });, which allows Pulumi to do its magic lifting thing to access properties (e.g. const newResource = new YourResource(name, { loadBalancerArn: elb.arn, ... });).little-cartoon-10569
04/22/2021, 8:30 PM