sparse-intern-71089
02/28/2019, 3:30 PMwhite-balloon-205
Input<string>
, so could be something you compute as part of an output of another resource. This is certainly not the most common case though.cold-coat-35200
03/01/2019, 2:45 PMimport * as pulumi from '@pulumi/pulumi'
async function run() {
const mainStackRef = new pulumi.StackReference(`stackRef-main`, {
name: `mainStack`
})
const fixedIpSubnetIds: pulumi.Output<string[]> = mainStackRef.getOutput('fixedIpSubnetIds')
const fixedIps: string[] = await new Promise((resolve, reject) => {
fixedIpSubnetIds.apply(t => resolve(t))
})
console.log(fixedIps)
}
run()
It logs the ips, even during pulumi preview, I assume because that Output value already known.
Can we rely on this behavior or this is not guaranteed?white-balloon-205
fixedIpSubnetIds.apply(t => console.log(t))
I'm not positive you can also rely on the code as you wrote it - for example, during previews - though I expect that you can.
Is your real use case more complex than console.log
? I'd be interested to see more of it to understand how you want to use the value from the StackReference
.cold-coat-35200
03/01/2019, 5:10 PMcold-coat-35200
03/01/2019, 5:14 PMpulumi.Output<string[]>
is a case, when we need to create resources in apply, I thought we could avoid that(based on this example), so the main idea is to get the string[]
values with this trick and create resources looping through that, this way we could see the resource changes during preview toocold-coat-35200
03/01/2019, 5:17 PMcold-coat-35200
03/01/2019, 5:55 PMcold-coat-35200
03/01/2019, 5:57 PM