https://pulumi.com logo
#dotnet
Title
# dotnet
g

gray-ambulance-59402

07/21/2020, 7:27 AM
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

tall-librarian-49374

07/21/2020, 7:41 AM
If using the resource args as a property of component args works for your scenario, I think that’s a good option
g

gray-ambulance-59402

07/21/2020, 7:56 AM
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

tall-librarian-49374

07/21/2020, 7:58 AM
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

gray-ambulance-59402

07/21/2020, 8:01 AM
Thanks