Hello, I had a query about using component resourc...
# dotnet
g
Hello, I had a query about using component resources arguments in Pulumi. More specifically how I can extend some of the existing resources args, rather than re-declaring them all in our own classes? For example in a use case of having a component resource for a Virtual network and subnets, I would like to expose the majority of the resource args into the component resource but add some additional arguments for conditional creation and loops or to set a default value for some of them. I can see all of the args classes are sealed, so is the standard to re-declare them in our own class or to create another that includes these args classes as properties?
t
If using the resource args as a property of component args works for your scenario, I think that’s a good option
g
Thanks @tall-librarian-49374- That would work for most scenarios. I guess the only downside of doing it this way (Correct me if i'm wrong?) is that if I want to override a value to be set as default, it cannot be hidden from the args so a consumer of the component might set it as one value but it will then get overriden. (Thinking of a security option that I would like to enforce on the resource)
t
Yes, indeed. You could prohibit those scenarios by runtime checks in constructors, but not at compile time.
TypeScript is actually quite powerful for such scenarios, where you can define types based on the shapes of other types and mix them together nicely. .NET is quite a bit more rigid, so you’d either have to duplicate, or allow inconsistencies mitigated at runtime.
👍 1
g
Thanks