https://pulumi.com logo
#dotnet
Title
# dotnet
b

bored-activity-40468

07/15/2020, 12:55 AM
@tall-librarian-49374 I'm working with @strong-plastic-28250 on this project. He's new to C# and I've been working with it for several years. The question I have with this snippet is, are there any downsides to being explicit with async await? I see the comments in RunAsync and how it looks for all [Ouput] attributes and waits/loops until they've completed. Could the same be achieved without using [Output] attributes, using async awaits, awaiting RunAsync and within that, using Task.WaitAll? Maybe this is only an issue with StackReferences. It seems that to use something from a StackReference in the creation of a resource needs to happen within the
.Apply(func)
which feels sort of like
.ContinueWith(func)
which is what async await tries to avoid, I think.
t

tall-librarian-49374

07/15/2020, 6:11 AM
Yes, you should be able to do that..
You can either derive from the
Stack
class or pass a function to
RunAsync
, both will work including outputs.
I don’t think this is related to the error from James though?
I also responded in the thread above
b

bored-activity-40468

07/15/2020, 1:40 PM
Is it correct to say that if I wanted to use some value from a StackReference, like creating a LoadBalancer, I would need to create the LoadBalancer withing the Apply? Output.Create won't away right?
t

tall-librarian-49374

07/15/2020, 1:42 PM
You could assign values from a stack reference to the Load Balancer properties.
Creating resources inside Apply is not recommended.
b

bored-activity-40468

07/15/2020, 1:44 PM
So if a value in a stack reference is needed and GetOutput is being used, how do you know if that task will complete before the creation of the resource that uses the value?
async await make async usable in a sync fasion, i'm trying to understand how [Output] and Apply does that.
t

tall-librarian-49374

07/15/2020, 1:47 PM
Outputs take care of ordering for you, that’s the beauty. Once you have an output, you can freely use it everywhere.
Outputs are based on Tasks internally and we do completion sources etc behind the scenes.
b

bored-activity-40468

07/15/2020, 1:50 PM
So outputs, regardless of how many, are resolved before resource creation?
t

tall-librarian-49374

07/15/2020, 1:53 PM
Yes. You can define a resource using unresolved outputs (as you do almost always, e.g. using a bucket name for a bucket object before the bucket exists). The actual creation operation will fire once all outputs-given-to-inputs are resolved.
b

bored-activity-40468

07/15/2020, 2:04 PM
So how do you pass Output<InputList> to Subnets on a LB creation?
If you have
[Output] public StackSubnets {get; set]
t

tall-librarian-49374

07/15/2020, 2:34 PM
The type for
subnets
should be
Output<ImmutableArray<string>>
. Also, you don’t need to make subnets the output of your stack, just declare a local variable.
Subnets = subnets
should work then
👍 1