OK, found this in the docs eventually: <https://ww...
# typescript
l
OK, found this in the docs eventually: https://www.pulumi.com/docs/intro/concepts/resources/#explicit-provider-configuration The example for a
ComponentResource
, doesn't pass the
opts
to the child resources. It only passes it to
super
. I assume the correct explicit provider is used then for the child resources. But if I pass
transformations
in
ComponentResourceOptions
, are these implicitely passed to all the child resources as well?
l
As far as I know, you must pass the correct provider via opts to all child resources. I have always done this and never had an issue.
I have also always gone out of my way to make component resources be single-provider only, and to design the relationship between component resources accordingly.
So for this case, instead of a single component resource with a map of two providers, I might create a GCP component resource, and a separate k8s component resource that has the GCP resource as in input property.
Not that it can't be done via two providers, I just like the cleanliness and simpler resulting API. It makes things like testing / faking that much simpler.
l
@little-cartoon-10569 got it working using multiple providers. You may only pass them to
super
, not to your child resources. Provider lookup seems to work correctly after that.
And what a pity that you keep your ComponentResources single provider. Cross-tech stack is the main use case I have in mind for ComponentResource, for which I am implementing the first occurrence at this very moment.
l
I may change my mind when I find a good use case. Right now, in you scenario, I would be passing the k8s resource around, and it would effectively have cross-tech functionality, since it can call methods on the GCP resource passed to it. There would be tight cohesion (since the k8s resource wraps the GCP resource and seems, from the caller's pov, to manipulate GCP) and low coupling (since the k8s resource does not do anything with GCP directly, it delegates to the GCP resource for that).
Good to know about passing providers to super though. I never tested that, even though I always do it. I have required explicit providers at all times. A few extra lines of code here and there... ¯\_(ツ)_/¯