I don’t really get what the `registerOutputs()` me...
# general
f
I don’t really get what the
registerOutputs()
method is for ? In the example here https://pulumi.io/reference/component-tutorial.html a component property
this.bucketName
is added. In fact we can access the
S3Folder.bucketName
without using
registerOutputs()
so I don’t see the point here ?
w
The outputs that are registered on a component are stored in the checkpoint file and displayed in diffs in the CLI and in app.pulumi.com. It is true that currently this is separate from the set of properties that are available via the programming model itself. To first approximation you don't have to provide outputs, but it often makes sense to include them just for presentation in these places. We will likely add more ways these outputs will get presented/used over time. We are also thinking about how we might closer unify the outputs and the properties on the component itself. On normal resources (CustomResource) these two ideas are more closely aligned, and we'd like to bring them closer together for components too ideally.
f
Ok got it, thanks. So using it right now is not mandatory and does not have any influence on the way I build and sequence my components.
w
That's right. Note that explicitly calling
registerOutputs
when the component is done registering it's children is generally a good idea even if there are no outputs (or you have not decided yet what outputs to publish). That's because the CLI dislay will show animating
...
until the resource call
registerOutputs
or execution finishes. So you'll get a better idea of status in the CLI if your component reports when it is done adding children.
f
I’ll try that, thanks. btw I was previously thinking this method was equivalent to the exports from the main file and complementary, but these component outputs are not accessible with
pulumi stack output
or any other way, right ?
w
That’s right. FWIW - The stack outputs are actually just the outputs of an implicitly created
Stack
component which all resources without a parent are implicitly patented to. Any exports from the entry point module are turned into outputs on that
Stack
resource.