I have a class extending `pulumi.ComponentResource...
# general
f
I have a class extending
pulumi.ComponentResource
, let’s call it
MyComponent
, creating in its
constructor
a
k8s.core.v1.ConfigMap
and a
k8s.helm.v2.Chart
the former getting a direct reference to it in the later
values
args. Both have their
opts
like
{ parent: this }
,
this
obviously referencing
MyComponent
.
MyComponent
is called with
opts
like
{ providers: { kubernetes: k8sProvider /* a working k8s.Provider instance */ } }
In this situation I get this error :
error: Error: Explicit providers may not be used with component resources
Where things get weirder is that if I remove
opts
along with the parent reference from the
ConfigMap
(and only from this one), the error disappear. I tracked down the error in
pulumi.ComponentResource
:
Copy code
if (opts.provider !== undefined) {
            throw new errors_1.ResourceError("Explicit providers may not be used with component resources", opts.parent);
        }
That does not make any sense for me in this situation, I don’t even set an
opts.provider
anywhere. Is this intended (and if so I could use some help to understand it) or should I open an issue ?
w
Are you sure you aren't passing the
opts
from the component down into a child somewhere - like
opts: opts
or
opts: {...opts, parent: this}
. I've seen this error when I accidentally did this. I'm hoping we'll be able to clean up some of the error case here as part of https://github.com/pulumi/pulumi/issues/1802, I'll add a note referencing this specific issue to that.
f
Yes, I can confirm with certitude only
{ parent: this }
is passed down explicitly to each child of my component.
w
Which resource is this error reported against for you? (and is there any additional detail you can share in DM?)
f
I will prepare a summary of everything and will send that to you in DM