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
echoing-dinner-19531
08/25/2025, 6:20 AM
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
delightful-queen-14969
08/25/2025, 6:33 AM
Interesting that they are not supported. Thanks for letting me know
e
echoing-dinner-19531
08/25/2025, 6:35 AM
Its because the stack resource isn't propagated through to the construct call, so needs a little protocol fix up.
a
aloof-chef-41549
08/27/2025, 5:38 PM
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
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.