This message was deleted.
# general
s
This message was deleted.
r
yes, generally in C# ToString is useless 😞. I think you need to look at Output<'t>.Format instead of tostring: https://github.com/pulumi/pulumi/blob/master/sdk/dotnet/Pulumi/Core/Output.cs#L57
f
So Output.Format will still return an Output<string> type.
Copy code
Output.Format($"Test String: {args.Name}"))
Pulumi.Output`1[System.String]
or
Copy code
$"Test String: {Output.Format($"{args.Name}")}";
Test String: Pulumi.Output`1[System.String]
I am still unable to get the underlying string value of the input/output variable
Basically I am passing variables to my component, then trying to template a file with these variables which need to be sent in as a string for the template but I just keep getting Pulumi.Output`1[System.String] type and really just need the value.
t
You can’t get a value from an output. @fast-dinner-32080 you showed the right way to format a string with outputs.
More often than not you actually don’t need to get the value.
Apply
/`Format`/`Tuple` them and pass to the next input somewhere.
f
Okay I was thinking that too. Basically have to shift how I work with the variables in the language where I can't expect it to work 100% like a regular .net program due to the special types.
t
Yes. Some outputs receive their values after your main program function completed and only when the actual resources were created. So you can’t get those values while it’s still running.
r
it's viral in the same sort of sense as tasks/promises. Once you need to extract the value you need to be 'in' the wrapper-type
f
Ah yea that makes a lot of sense. Due to how the values are gathered or even generated.
It finally clicked for me. I can create the rendered template using whatever library/method I want but if I want to use input/output values I need to do it in the apply method (wrapper). So I threw it in a Output.Tuple, rendered the template, and then returned it to the new Output<string>. This wont actually show in the details when I preview which is probably what threw me off before since it is generated at runtime.
Then i passed that to the VM as userdata and it worked.
I wonder if adding an example like this in the docs would be useful. Most things about output/inputs are just to transform them into other strings. Would be cool to show that more complex things like what I did also needs to be in an tuple/apply. That is probably how I got thrown off at first.
t
You are right. We discussed that just a few hours ago. It would be awesome if you could file an issue under https://github.com/pulumi/docs and explain the example that you miss.
f
🎉 1