https://pulumi.com logo
Title
f

freezing-twilight-25806

03/10/2023, 5:03 PM
Hi guys! I'm trying to figure out how can I manage dependencies here:
import * as k8s from "@pulumi/kubernetes";
import { FileAsset } from "@pulumi/pulumi/asset";
import { project, stack } from "./globals";

export const release = new k8s.helm.v3.Release(`${project}-${stack}`, {
    chart: "./nats",
    atomic: true,
    createNamespace: true,
    namespace: `${project}-${stack}`,

    valueYamlFiles: [new FileAsset(`./nats/${stack}-values.yaml`)],
    values: {
        Lb: true,
        LbServiceAnnotations: {
            "<http://service.beta.kubernetes.io/aws-load-balancer-name|service.beta.kubernetes.io/aws-load-balancer-name>": `${project}-${stack}`,
        }
    }
})

const nlb = aws.lb.getLoadBalancerOutput({
    name: `${project}-${stack}`,
});
After
pulumi preview
I got an error on NLB lookup, because it doesn't exist, obviously:
reading ELBv2 Load Balancers: couldn't find resource
Inside the helm chart there is a logic to create NLB and I want to get NLB dns name just after creation to manage route53 records afterwards Is it possible to add any dependency condition or kind of in such case?
b

billowy-army-68599

03/10/2023, 5:52 PM
so your
nlb
call is running at the same time as your helm release call, because there’s no dependencies between them. The way to handle this is to use the
apply
callback mechanism. There’s an example here: https://www.pulumi.com/registry/packages/kubernetes/api-docs/helm/v3/release/#query-kubernetes-resource-installed-by-helm-chart (pulumi interpolate is just syntactic sugar around
apply
f

freezing-twilight-25806

03/10/2023, 6:55 PM
It would work if inside
pulumi.interpolate
is an output from
export const release =...
, but in my case it is not an output, its a know predefined value If I specify something like this:
const nlb = aws.lb.getLoadBalancerOutput({
    name: pulumi.interpolate`${release.status}`,
});
It works, but it doesn't fit the needs. If I do something like this:
const nlb = aws.lb.getLoadBalancerOutput({
    name: pulumi.interpolate`${project}-${stack}`,
});
export const nlbDnsName = nlb.dnsName;
It return the same error Also, I tried to set LB name with values and use it as input, but with no luck: `pulumi.interpolate`${release.values.LbName}`,`
b

billowy-army-68599

03/10/2023, 7:13 PM
you need to use an output value from the release, if you can’t use interpolate, do something like:
const nlb = release.status.apply(status => ...)
f

freezing-twilight-25806

03/13/2023, 8:43 AM
@billowy-army-68599 thank you! it works 🙂