Hi, Is there a solution to use ```const elb = aws...
# aws
b
Hi, Is there a solution to use
Copy code
const elb =  aws.elb.getLoadBalancer( { name: elbName });
with elbName being an output. Is there a way around? Otherwise I don’t see how to address my use case, which I don’t develop here…
w
I’m not sure I’m following your question. Do you mean
elbName
is an output property of another resource and you want to use it in the
getLoadBalancer
call?
b
yes, that’s actually my question 🙂
w
If so,
.apply()
is your friend: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#apply So it’ll be something like
Copy code
const elb = otherResource.elbName.apply(elbName => aws.elb.getLoadBalancer({name: elbName})
b
that’s what I did but I get a side effect
It seems to be linked to this: (from the doc) During some program executions, 
apply
 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.
w
Yes, that’s true, but since you are only doing a
get
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.
b
I get it from an helm ressourceProperty. It’s actually the name of a kubernetes service LB which has the name of the elb
w
Ahh. So, I guess I go back to my original thought that since it’s a
get
function it should be fine to use the
.apply()
logic in this case. Is it actually causing issues for your deployment?
b
yes but the issue might not come from there. I also find strange that
Copy code
aws.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?
w
yes
b
thank you for the info!
l
You might not need to use apply or then in these cases. You can wrap Promises in Outputs (e.g.
const 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, ... });
).
This only works when you're passing the promise-wrapped-in-an-output to a Pulumi constructor, but that is the most common use case, so it's often helpful.