melodic-easter-82419
05/13/2021, 4:18 PMexport const resources = pulumiResources.reduce(
(result, res) => ({
...result,
[res.location]: {
// This variable is Output<string>
resourceGroup: res.resourceGroup,
otherProperty: res.foo,
},
}),
{}
);
Problem I am running into is when I try to run pulumi.apply in order to set the key as a string. When I run this, I will either only get the first item in the list applied to the object or I will get the last object of list applied.
export const resources = pulumiResources.reduce((result, res) =>
res.location.apply(
(location) => ({
...result,
[location]: {
// This variable is Output<string>
resourceGroup: res.resourceGroup,
otherProperty: res.foo,
},
}),
{}
)
);
I tried doing a pulumi.all on the resources and this didn’t work either.steep-toddler-94095
05/14/2021, 7:02 AMres.location.apply()
returns an Output<T>
which becomes the type for result
. Given that, I'm not sure what ...result
ends up being but it's definitely not the structure you intend. I am not sure if it's possible to be honest 🤔 You'd need to find a way to convert an Array<Output<string>>
into Output<Array<string>>