Hi All, What is the best way to use an Output<...
# general
f
Hi All, What is the best way to use an Output<string> in the name of a new resource. Context: I am trying to use an output from a previous resource to create deterministic naming of pulumi resources down the chain.
Copy code
Team team = new Team("<name here built using an Output<string> from a previous resource>", new TeamArgs());
b
I'm not sure that's possible today
f
Thats unfortunate, it seems like it would be a pretty foundational piece of moving to a full programming language to be able to create deterministic patterns like this. Even some type of feature where someone can force executing this resource serially and awaiting the promise would be super useful.
b
Someone from Pulumi should comment (though I feel I’ve seen similar questions before), but I think the resource name needs to be known deterministically at runtime and not just at resolution time.
e
There is an issue for this https://github.com/pulumi/pulumi/issues/5234 The problem is the engine needs the logical name to be known even during preview. Most resources will support a "name" input property as well to control the name of the resource in the cloud (although that does miss out on using Pulumi's automatic appending of a hash to reduce the chance of name conflicts). If you really must have the logical name set based on another resource you'll need to create the Team resource within an apply call.
Copy code
outputString.apply(str => new Team(str, new TeamArgs()))
Be aware that this will not always show up in previews as it can only run that code if the output string's value can actually be retrieved (which if it requires creating a cloud resource can't happen at preview time)
👍 1