This message was deleted.
s
This message was deleted.
s
Keep it all in a single "main" until you have an obvious reason to use multiple files/modules/classes.
An obvious reason would be like "I have 1000 lines of code in one file".
a
thanks. this is existing infrastructure I'm working on importing in. This is not for a personal project, but will encompass quite a few resources. That said, I think I might have worked out a way forward, but am still tinkering
s
IaC is not as easily refactored as regular code because of the stateful nature (although it can definitely be refactored in Pulumi with aliases), so you're gonna want to keep it a little dumber than app code even if it does not read as pretty.
I recommend you try regular ol' static functions first, then Components if you need them. Try to group resources logically (like a whole service, or foundational networking) rather than by a fine-grained type. I think you'll find it's easier to work with. In general (IaC and app code), you know your code org is right when changes are confined to a small number of files that live in the same place.
(Which is also why I think every MVC framework I've seen does it wrong, but that's another take for another time.)
a
gotcha. I definitely need to have "global" things in one place, and "product" specific items elsewhere. One of the things I'm kicking around is how to reference something across multiple resources. For example, a single policy that needs assigned to several groups. The group requires the policy ARN. The major hurdle was I am attempting to create some generic methods and interface implementations, where method would basically just do a "execute the constructor for any class which implements IPolicy" as an example.
s
An IAM policy? Just create a managed policy and then attach it to multiple principals.
b
Advanced C# example with Automation API, it's nice to look at other dotnet examples https://github.com/gitfool/Pulumi.Dungeon