Looking for some guidance on best practices for what can be outputs of a custom ComponentResource. More specifically how should one share a resource created by the component resource so it can be referenced from a different project / stack. Can resource object be an output?
Case in point: Project A uses custom ComponentResource to provision a complex set of resources including a public IP address (in Azure). We want to reference this public IP address resource in a different project for registration in DNS / firewall / etc. What should the output property be?
03/29/2021, 4:56 AM
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.
However, there is no built-in way of doing this.
(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!)
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.
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.