This message was deleted.
# typescript
s
This message was deleted.
g
I suspect your problem is that you’re trying to convert an Output back to a raw value (list of strings), which isn’t possible.
If you need to access the values of an Output, it has to be within an apply. The code in an apply is a callback that runs once the value is available.
Copy code
const gcpConfig = envConfig.getOutput("gcpConfig")
gcpConfig.apply((regions: string[]) => {
    for (const region of regions) {
        // Do stuff here
    }
})
a
I need to be able to pass the output into a customresource as an argument and iterate over its values there. If I were iterating over it outside of the resource I'd probably be fine - but I thing a lot of my struggle is figuring out what the type of the arguement for the CR should be. I've been trying
string[]
which obv. doesn't work, and
pulumi.Input<string[]>
but that doesn't give me the ability to apply or iterate. Does it make sense for my custom resource to accept a
pulumi.Output
as an argument? feels wrong, but maybe I'm getting hung up on naming
g
In this case, you’d likely want a
pulumi.Input<string[]>
, which can handle Outputs as well as raw values. If you need to interact with that value in the custom resource logic, then you can do something like
pulumi.output(myInputValue).apply(x => {...})
l
Would you not then be trying to create some resources (the ones that uses
const regions
) inside an
.apply()
? That doesn't work, I think?
When I ran up against this problem in my workflow, the only solution I found was to copy the relevant outputs to my stack config. So long as they're not marked as secrets, the values can be used immediately.