pulumi: Dynamic resources in Python don't work outside of __main__
Instantiating a dynamic resource in Python outside of the __main__
module fails. This was filed as #4100 but that issue was incorrectly closed, in my opinion! The repro there is totally legit and I am copy/pasting it below.
Steps to reproduce
Run pulumi up
on this program:
# __main__.py
import custom_resource
# custom_resource.py
import pulumi
import pulumi.dynamic
class CustomDynamicResourceProvider(
pulumi.dynamic.ResourceProvider,
):
pass
pulumi.dynamic.Resource(
provider=CustomDynamicResourceProvider(),
name='my-resource',
props={},
)
It will incorrectly fail:
Previewing update (dev)
View Live: https://app.pulumi.com/benesch/pulumi-4100/dev/previews/b9c38f39-280d-40d2-9bed-e6c5ccd7636c
Type Name Plan Info
+ pulumi:pulumi:Stack pulumi-4100-dev create
└─ pulumi-python:dynamic:Resource my-resource 1 error
Diagnostics:
pulumi-python:dynamic:Resource (my-resource):
error: Exception calling application: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
I’ve put this together in a Git repository, if that’s easier: https://github.com/benesch/pulumi-4100
As far as I can tell, all the dynamic resource examples in the pulumi/examples repository do so from __main__
so this bug is never observed.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (12 by maintainers)
Commits related to this issue
- Allow Python dynamic provider resources to be constructed outside of `__main__` The underlying library `dill` that we use for serializing dynamic providers into Pulumi state for Python dynamic provid... — committed to pulumi/pulumi by lukehoban 3 years ago
- Allow Python dynamic provider resources to be constructed outside of `__main__` (#7755) The underlying library `dill` that we use for serializing dynamic providers into Pulumi state for Python dynami... — committed to pulumi/pulumi by lukehoban 3 years ago
- Revert "Allow Python dynamic provider resources to be constructed outside of `__main__` (#7755)" This reverts commit ebb0e6aaed83a2275bed0284ec96fbb4ebfc3d67. The changes in #7755 introduced a regre... — committed to pulumi/pulumi by lukehoban 3 years ago
- Revert "Allow Python dynamic provider resources to be constructed outside of `__main__` (#7755)" (#7889) This reverts commit ebb0e6aaed83a2275bed0284ec96fbb4ebfc3d67. The changes in #7755 introduc... — committed to pulumi/pulumi by lukehoban 3 years ago
Is there a workaround for this issue? Currently hitting this issue. It happens even if it’s written inside
__main__