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> |
||
---|---|---|
.. | ||
automation | ||
data/lazy_import_test | ||
dynamic | ||
langhost | ||
provider | ||
runtime | ||
__init__.py | ||
conftest.py | ||
helpers.py | ||
test_broken_dynamic_provider.py | ||
test_config.py | ||
test_deprecated.py | ||
test_invoke.py | ||
test_monitor_termination.py | ||
test_next_serialize.py | ||
test_output.py | ||
test_resource.py | ||
test_runtime_to_json.py | ||
test_stack_reference.py | ||
test_stack_registers_outputs.py | ||
test_translate_output_properties.py | ||
test_types_input_type.py | ||
test_types_input_type_types.py | ||
test_types_output_type.py | ||
test_types_resource_types.py | ||
test_urn.py | ||
test_utils.py |