What's the right way to lookup a resource that's b...
# general
f
What's the right way to lookup a resource that's been created in a loop to use in the
parent:
block of another resource? I got stuck because I can unwrap the promise to check the string, but I can't seem to do that and keep a reference to the resource which is what I actually need. For example, say I created a bunch of
kubernetes.core.v1.Namespace
resources in a function and now I have an array of them. What's the right way to do this:
Copy code
// namespaces is an array of kubernetes.core.v1.Namespace
const myNamespace = namespaces.find(
    ns => ns.metadata.name === 'mynamespace' // Usual Output<string> is not a string problem
);

// Use mynamespace as parent
new k8s.helm.v2.Chart(
    'myChart',
    {
        path: chartPath,
    },
    {
        parent: myNamespace
    }
);
t
I’d say you’d have to return more information from the loop, e.g. not an array of namespaces but a map of namespaces by name. You can’t extract the name from outputs for the purpose of defining the parent.