Hey folks, is there now a recommended way to itera...
# general
Hey folks, is there now a recommended way to iterate over an
other than
apply(l => l.map(...))
? I've been looking at (1), which suggests it's best not to create resources in an
, and (2) which suggests that sometimes this is the only way to do it. 1. https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#apply 2. https://github.com/pulumi/pulumi/issues/5392
1 is because these won't always show up at preview time so your actual update may differ from preview. 2 means that sometimes you still need to do this 😞 I do have some ideas around making things better here, but for now apply is the way to handle this.
@echoing-dinner-19531 Makes sense to me. I tried a couple of different patterns, but in cases where you don't know the length of the array up-front it seems that
is still necessary. Ended up refactoring to make it static in the case I was looking at. Care to share any of your ideas? ;)
Two ideas. 1 is adding a
function so we can at least error out that you have resources trying to be created in preview, but
would allow you to still run an
without that error blocking the whole operation (this is exactly the same behaviour as TF) 2 is adding a applyMap function that would let the engine understand iteration, so it wouldn't be able to say how many resources we're going to be made but it could say 0 or more.