I am building a new component and I want to pass t...
# contribute
b
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
can you share your code, or some of it?
b
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
I believe that’s in
core
args.cluster.eksCluster.core.endpoitn
l
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
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
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
Yeah, that what I saw in some of the docs just doesn’t seem to want to work for me
l
Post a code snippet? Slack's "Create a Text Snippet" works best.
b
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
Onesec, looking up that resource...
l
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
normal way ie
cluster, err := eks.NewCluster(ctx, "cluster", &eks.ClusterArgs{
l
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
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
So the problem is purely syntactic? Pulumi is creating the correct resource? Maybe #golang might find someone better able to help...
b
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
It's got to be a syntax problem. The value doesn't get discarded by Pulumi...
b
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
Would be better to file an issue at this stage I think
b
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