mirror of https://github.com/pulumi/pulumi.git
a3cdbad64c
Python dynamic providers get serialised and deserialised, and run in the `pulumi-python` plugin process. This causes issues when trying to use `pulumi.config.Config` in a dynamic provider: * Using `Config` at runtime fails because the process is not setup with the current configuration * When the dynamic provider implementation is in the `__main__` module, the dynamic provider serialization attempts to serialize the global `SETTINGS` object, which pulls in protobuf definitions, which are not serializable by `dill`. To provide a stable API to access configuration in dynamic providers, the provider classes (ResourceProvider) can now implement a `configure` method which is called during provider initialization. ```python class SimpleProvider(ResourceProvider): password: str def configure(self, req: ConfigureRequest): self.password = req.config.get("password") def create(self, props): # Use `self.password`. ... ``` The `configure` method is called when a provider is deserialized. Since we cache the deserialization result, we guarantee that this is only called once per program, and this process level cache serves as a plugin registry. Fixes https://github.com/pulumi/pulumi/issues/17050 --------- Co-authored-by: Will Jones <will@sacharissa.co.uk> |
||
---|---|---|
.. | ||
Pulumi.yaml | ||
__main__.py | ||
requirements.txt |