Hi all. I apologize if there's a thread on this al...
# dotnet
c
Hi all. I apologize if there's a thread on this already that I missed. I've been away from day-to-day coding and IaC for a while, so I'm just getting my head back into the game. I'm still new to Pulumi overall. I'm looking for a blog post, video, whatever to learn about best practice recommendations around organizing your .NET Pulumi code for modularization. As an example, I have a client that has a lot of Azure IaaS environments. They have a fair set of baseline configurations and standards around the VM configurations. Depending on the use case, I'd like to be able to use some class definitions (or even a class library) to create modules specific to VM types that they define (e.g. A domain controller, A VM hosting synthea (a synthic data creation tool, etc...). The goal would be to allow them to create a top level module project that would pull in classes/class libraries, allowing them to define the minimum number of properties for their local variation on the resource type and assemble the various custom resources into an environment. I hope this request is clear and makes sense. I'm happy to provide more detail and some examples where I've organized the same thing using BICEP. In the end, just links to samples, blog posts, etc to get me moving in the right direction will be helpful.
e
Given your just writing dotnet code a lot of the standard good library design for C# applies equally well to Pulumi. About the only Pulumi specific thing you'll really need to know about is Component Resources. Our devrel team might have some other resources when they get online in the US timezone.
c
@echoing-dinner-19531 - Thanks. A small sample would be helpful, hopefully the US folks can point me to one.
b
I believe there is a .NET sample in that component resources documentation. The trick with these is just to make sure you are always setting the parent on child resources, and that you are forwarding any providers provided to the component resource via custom resource options. I have done something similar to this - you'll want to publish a class library that exposes the component resources and their respective argument classes and that will be about it. I like to follow the way the various Pulumi providers define & name argument classes.
e
It's not dotnet or even Pulumi specific but I was pointed at this talk from the cloud engineering summit last year that may be of interest: https://www.pulumi.com/resources/reuse-dont-repeat-creating-an-infrastructure-as-code-module-library/
c
Thanks to both @echoing-dinner-19531 and @bored-oyster-3147 for your additional info. I haven't found or been told more fully formed samples in .NET. I'm planning to start to assemble one. As I get something together, I'll publish it to a repo and I may ping folks here to get some thought on it so we can evolve it into a relatively canonical sample.
e
If you think it makes sense feel free to raise a PR to add an example to https://github.com/pulumi/examples. We've got a few examples there of using ComponentResources but only one dotnet one so far (https://github.com/pulumi/examples/tree/master/classic-azure-cs-cosmosapp-component)
👀 1