https://pulumi.com logo
#typescript
Title
# typescript
l

little-whale-73288

09/27/2021, 9:05 AM
Hello, is it kosher to instantiate resource classes inside
.apply
callbacks?
Answering myself: nope: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#apply: "you should not allocate new resources inside of your callbacks either, as it could lead to 
pulumi preview
 being wrong"
In this case, what is the proper way of instantiating a resource per each of zones returned by https://www.pulumi.com/docs/reference/pkg/aws/getavailabilityzones/ ?
perhaps it's OK to do it inside
.then
on a promise, but not inside
.apply
on an output?
b

billowy-army-68599

09/27/2021, 3:11 PM
while we try and recommend not doing this, it's sometimes unavoidable, this seems like one of those cases
if you're okay with the preview being wrong, you can go with this
l

little-whale-73288

09/28/2021, 6:02 AM
thanks. It's an option, but OTOH we consider reliable previews necessary