https://pulumi.com logo
#general
Title
# general
a

able-camera-57198

11/06/2021, 4:01 PM
Is it okay to "output" resources from
ComponentResources
so that they can be passed elsewhere in the stack? For example:
Copy code
[Output]
    public Network ProjectNetwork { get; set; }

    // later...

        ProjectNetwork = new Network(
            "project",
            options: new()
            {
                Parent = this,
                DependsOn =
                {
                    computeService,
                },
            },
            args: new()
            {
                Name = "blablabla",
                AutoCreateSubnetworks = true,
            }
        );
g

green-stone-37839

11/06/2021, 4:43 PM
You can certainly do that however my preference is to expose resources from component resources using public readonly fields instead of outputs.
a

able-camera-57198

11/06/2021, 4:50 PM
Actually yeah, I get an error when it's not an instance of
Output<...>
.
I'll definitely switch them to public readonly 🙂
Or I guess I can do
{get; init;}
😉
2 Views