<@UB27BHS4B> is there some way to derive from one ...
# python
p
@incalculable-sundown-82514 is there some way to derive from one of the pulumi classes so that I can have a new resource that has its inputs resolved and called as part of the dependency process so that I can access the outputs of other resources? The only way I can see currently is to define a custom resource that has its own provider and pass in the cloud provider (eg AWS) as an option for its children to use. Does that mean I have to write something like pulumi_random as a provider so that the engine will call the appropriate invocations at runtime?
i
So in the JavaScript world, we have this thing we call a “dynamic provider” which lets you do pretty much that - you write a JavaScript class that implements create, read, update, and delete by doing code actions and the Pulumi engine arranges for them to be called at the correct time.
We don’t have this in Python because the JavaScript implementation relies on serializing the code of the provider itself. We could theoretically do this today with
pickle
, since it’s my understanding that CPython is technically capable of doing this.
You can derive from
ComponentResource
, but that doesn’t get you access to the “lifecycle hooks” of knowing when your dependencies got read/updated/deleted. We have a longstanding issue for that: https://github.com/pulumi/pulumi/issues/127
p
yup, we need that sort of serialization to get user code to the other side of the engine 🙂. Where is the code that deals with the JS dynamic provider? I’ll have a look at how hard it would be to pythonize it 😄
It’s not only knowing when they’re being CRUDed, it’s calling user code when that happens. There needs to be a way to define a provider that runs python the same way the dynamic JS provider runs JS. Hmm, interesting, if I had such a provider that called my own code that then tried to CRUD another resource that was controlled by another provider (eg AWS), that would set up an “interesting” set of loops to resolve inside the engine 😄