I always avoid this by passing only the required IDs around (the IDs of the constituent resources). But in theory you could either marshal and unmarshal the ComponentResource youself, or provide a "read-only" flag and write code that gets all the constituent resources, instead of newing them.
little-cartoon-10569
03/29/2021, 4:56 AM
However, there is no built-in way of doing this.
little-cartoon-10569
03/29/2021, 4:58 AM
(If someone were to write a general-purpose typescript marshaller/unmarshaller and come up with a nice pattern to choose between newing and unmarshalling, I know I'd use it!)
l
little-vegetable-79574
03/29/2021, 5:05 AM
If I understand correctly you are suggesting returning "native" ID of the created resource and using GetXyz to retrieve the resource elsewhere.
l
little-cartoon-10569
03/29/2021, 6:12 AM
Yes, that's one way of doing it. Or just storing the IDs, and deferring retrieving until it's actually needed. It often isn't: in a lot of cases, only the IDs of the resources are ever used.
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.