I'm getting the following error when I try to expo...
# python
d
I'm getting the following error when I try to export a value from within the constructor of a component resource:
Copy code
error: my-plugin:index:MyResource resource 'my-resource' has a problem: Unexpected <class 'Exception'>: Failed to export output. Root resource is not an instance of 'Stack':
What would have to be true for the root resource to not be a stack during the execution of
pulumi up
? Almost certainly I am doing something wrong, just trying to understand how to debug issues like this one
e
Is this a new style component (https://www.pulumi.com/blog/pulumi-components/)? I don't think stack exports work from those currently, you'll have to raise an issue to track getting that supported.
d
Interesting that they are not supported. Thanks for letting me know
e
Its because the stack resource isn't propagated through to the construct call, so needs a little protocol fix up.
a
It looks like the error happens because you're trying to call
pulumi.export()
inside the constructor of a
ComponentResource
. Export only work at the stack (root) level, not inside component resources. You can remove the
pulumi.export()
from the resource constructor and instead return the values from your
componentResource
via
self.register_outputs()
. then in your main.py, you can call
pulumi.export()
on the properties exposed by your component.