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

blue-pharmacist-31672

02/01/2023, 11:35 AM
Hi there, is it possible to export a value to pulumi stack outputs in .NET. There is a docs page for stack outputs here, but it only has examples in Typescript, Python, Go and YAML. I can't find anything by googling about it. Is it unsupported? Or are there some docs I am missing. Thanks! 🙏
e

echoing-dinner-19531

02/01/2023, 1:36 PM
Oh! Yes this is supported, i'll get that page updated not sure why it's missing dotnet. If your using a stack class you can set an export with an
[Output]
attribute: https://github.com/pulumi/examples/blob/master/aws-cs-s3-folder/WebsiteStack.cs#L37-L40 Or if your using the function based deployment you just return a dictionary of values: https://github.com/pulumi/templates/blob/master/aws-native-csharp/Program.cs
b

blue-pharmacist-31672

02/02/2023, 2:31 PM
Hey @echoing-dinner-19531 Thank you so much for this. I'm also wondering is unit testing for stack outputs supported as well? I followed the unit testing guide for .NET Pulumi here and it works great for stack resources. However if I wanted to also assert that the stack output is correct, would I do that with a particularly resource in the array that the mock function returns? (Nothing looks obvious from class naming to me) Or is there a different method for testing these things?
e

echoing-dinner-19531

02/02/2023, 3:36 PM
I'll admit I've not got as much experience with our test setups as I should! But I think there should be a Stack resource returned in the resources array, and the stack outputs will be in the
Outputs
property.
b

blue-pharmacist-31672

02/03/2023, 1:20 PM
Hi @echoing-dinner-19531 Apologies to keep "@ing" you. I took a look at the code and it looks like there is support for outputs on the overloads for the `TestAsync` function however if you use the `TestWithServiceProviderAsync` function then it only supports the resource array output and I couldn't find any type that corresponds to
Outputs
in there. Wondering if this is not supported with service providers for a reason? Or if it's just an oversight? Or if there's some other intended way to get the outputs out for testing when you use a service provider?
e

echoing-dinner-19531

02/03/2023, 1:24 PM
Probably just oversight 😞
Raise an issue we can look at aligning them
b

blue-pharmacist-31672

02/03/2023, 1:25 PM
Thank you! 😄 Will do!
@echoing-dinner-19531 I've raised an issue and an associated PR to hopefully address it. Though I'm not sure if this is a change that requires changelog updates.