https://pulumi.com logo
#contribute
Title
# contribute
b

brash-gigabyte-81569

11/15/2022, 9:22 PM
I am building a new component and I want to pass that component an eks.Cluster ( as defined in pulumi/eks) as cluster then within the constructor of the component I am building I am trying to make use of things like
args.cluster.eksCluster.endpoint
. Everything compiles and builds but when I go to use that endpoint value it is outputting it as empty. I’ve tried doing things like
args.cluster.eksCluster.endpoint.apply(endpoint => endpoint)
and
args.cluster.eksCluster.apply(cluster => cluster.endpoint)
. I can’t think of anything else I should try and it is probably something simple I am missing.
b

billowy-army-68599

11/15/2022, 9:24 PM
can you share your code, or some of it?
b

brash-gigabyte-81569

11/15/2022, 9:26 PM
Sure
Copy code
export interface ComponentArgs {
    cluster: eks.Cluster;
}
Copy code
export class Component extends pulumi.ComponentResource {
    constructor(name: string, args: ComponentArgs, opts?: pulumi.ComponentResourceOptions) {
        super("blah:index:Component", name, args, opts);

        const componentRelease = new k8s.helm.v3.Release("component", {
            chart: "{chart_goes_here}",
            version: "{version_goes_here}",
            namespace: "{namespace_goes_here}",
            values: {
                "clusterEndpoint": args.cluster.eksCluster.endpoint,
            },
            createNamespace: true,
        }, {
            parent: this,
        });

        this.registerOutputs({});
    }
}
b

billowy-army-68599

11/15/2022, 9:30 PM
I believe that’s in
core
args.cluster.eksCluster.core.endpoitn
l

little-cartoon-10569

11/15/2022, 9:31 PM
cluster
is an eks.Cluster.. I don't see a property
eksCluster
on that. https://www.pulumi.com/registry/packages/aws/api-docs/eks/cluster/. Should that line be
clusterEndpoint: args.cluster.endpoint
?
b

brash-gigabyte-81569

11/15/2022, 9:36 PM
message has been deleted
Trying using core now
core didn’t work but I am calling at day for now
back at it now. So I should be able to pass a resource into a component as an argument and it should handle the resolving the the values, right? Anyone else do this so I can look at how they have it setup?
l

little-cartoon-10569

11/16/2022, 9:04 PM
Yes. Onesec I'll find an official example...
Nope, can't find one. But if you want to pass a resource into a ComponentResource, go ahead. You can use its outputs in the normal way, inside your ComponentResource's constructor.
b

brash-gigabyte-81569

11/16/2022, 9:09 PM
Yeah, that what I saw in some of the docs just doesn’t seem to want to work for me
l

little-cartoon-10569

11/16/2022, 9:09 PM
Post a code snippet? Slack's "Create a Text Snippet" works best.
b

brash-gigabyte-81569

11/16/2022, 9:09 PM
same one as above
basically trying to pass the cluster from pulumi-eks into my component so I can grab all the various pieces to setup roles, charts, etc
l

little-cartoon-10569

11/16/2022, 9:10 PM
Onesec, looking up that resource...
l

little-cartoon-10569

11/16/2022, 9:14 PM
So
args.cluster
is that class,
args.cluster.eksCluster
is from
@pulumi/aws/eks
, and endpoint is undefined? How did you create the
@pulumi/eks
cluster? That certainly looks okay to me...
b

brash-gigabyte-81569

11/16/2022, 9:15 PM
normal way ie
cluster, err := eks.NewCluster(ctx, "cluster", &eks.ClusterArgs{
l

little-cartoon-10569

11/16/2022, 9:17 PM
Would you be able to log a few key values, or export them as stack outputs to examine them?
cluster.eksCluster.id
would be good to check...
b

brash-gigabyte-81569

11/16/2022, 9:17 PM
the fact that it should work, will keep me going
yeah i am output the endpoint in the outputs already and every thing is good there
l

little-cartoon-10569

11/16/2022, 9:22 PM
So the problem is purely syntactic? Pulumi is creating the correct resource? Maybe #golang might find someone better able to help...
b

brash-gigabyte-81569

11/16/2022, 9:24 PM
the endpoint which i output from the cluster resource is correct at the end, the endpoint that i try to use from that cluster resource inside the component i am creating is blank when it is run
so in the example the clusterEndpoint is empty
i’ll figure it out for sure or give up and pass individual outputs to the component
l

little-cartoon-10569

11/16/2022, 9:26 PM
It's got to be a syntax problem. The value doesn't get discarded by Pulumi...
b

brash-gigabyte-81569

11/17/2022, 5:47 PM
dunno, I gave up and switched it to using the fields I currently need instead of passing the whole resource
ie
Copy code
ClusterEndpoint: cluster.EksCluster.Endpoint(),
ClusterName:     cluster.EksCluster.Name(),
instead of
Copy code
Cluster: cluster,
I feel like I have tried every combination of pulumi.Input, pulumi.Unwrap, pulumi.Outuput, nestings of each, as well as setting the property to
plain: true
in the schema, and I can’t seem to get the
Cluster
from pulumi-eks to resolve correctly when passed to a component. No compilation errors on the component, no errors when running pulumi up, but the fields I am trying to set using values from the Cluster just don’t output or get created. Is there a trick to getting these resources to work when being passed to a component that I am missing?
I feel like it has something to do with the nesting of pulumi.Outputs
https://github.com/pulumi/pulumi-eks/blob/master/nodejs/eks/cluster.ts#L1617
Copy code
* This is a variant of `Cluster` that is used for the MLC `Cluster`. We don't just use `Cluster`,
 * because not all of its output properties are typed as `Output<T>`, which prevents it from being
 * able to be correctly "rehydrated" from a resource reference. So we use this copy instead rather
 * than modifying the public surface area of the existing `Cluster` class, which is still being
 * used directly by users using the Node.js SDK. Once we move Node.js over to the generated MLC SDK,
 * we can clean all this up. Internally, this leverages the same `createCluster` helper method that
 * `Cluster` uses.
^ seems a known issue with Cluster
b

billowy-army-68599

12/01/2022, 9:18 PM
Would be better to file an issue at this stage I think
b

brash-gigabyte-81569

12/01/2022, 9:19 PM
Seems like the issue is known and with reasons on why it isn’t fixed/cleaned up yet
only thing I can think I would accomplish with an issue would be to request that it be documented better since I spent days trying to figure out what I was doing wrong and why I couldn’t get it to work
but I suppose it will at least it will help someone else if they search for the issues, so I will go ahead and do it
cc @microscopic-pilot-97530
9 Views