https://pulumi.com logo
Title
b

broad-chef-99140

09/10/2021, 4:11 PM
How to structure your .net files? What is the best practice for structuring the .cs files in a large stack within a project. In Terraform, you would typically group all of the resource related to the same "thing" into a .tf file For example for an Azure Function, the app service plan, storage and app service itself might all go into one .tf file. What is the equivalent for Pulumi to avoid having one giant .cs file for the stack (or is the answer that I should have a stack for each "thing" in my system and use Stack References to create inter-stack dependencies?). I have thought about using
partial class
but wanted to reach out to see if there are any conventions?
b

bored-oyster-3147

09/10/2021, 5:55 PM
I encapsulate related resources into component resources and separate them into separate files that way. My stack class then declares large numbers of resources with only a few high-level abstract component resource declarations.
šŸ‘ 1
For example a simple application's stack class might end up just declaring: ā€¢ cluster resources / anything shared ā€¢ backend component resource ā€¢ frontend component resource ā€¢ dns
Of course if you don't want to do the component resource route, you could just as easily place static classes in separate files with a static entrypoint function in each to organize your code. Then your stack constructor could just call those static functions.
b

broad-chef-99140

09/12/2021, 3:22 PM
Thanks @bored-oyster-3147 I'll take a look at that approach Do you know of a sample anywhere I could look at?
b

bored-oyster-3147

09/12/2021, 3:28 PM