This message was deleted.
s
This message was deleted.
b
@clever-cartoon-41433 a Pulumi application is a normal program - so you can bring non-pulumi packages and use those as part of the application
so you can create resource X, then call API package A, then create resource Y
all in the same program in an order you control
c
I need to shell into this after a resource is provisioned
b
so if it's a binary, then you'd need to use something like subprocess.run in Python (or the equivalent for the language you are using(
c
I know how to run a binary in typescript; the problem is that I need to run this binary after another resource is provisioned, during the pulumi up application, and then use the output as an input to another resource.
A k8s secret that one of my pulumi resources creates shortly after it is made has to be read and fed into another pulumi provider, and I need to use a cli to wait for + get that secret, or I need to have some busy waiting loop where I try to get the secret name over and over until a timeout or it gets read
b
I understand, you can bring that in as part of the pulumi program to do that
a pulumi program is just a program
so shell to the binary and run your command then then continue your application
this makes a call to an api and waits for that to happen and then continues with resources after that
similar thought process
c
I think what I need to use is a dynamic provider
b
ok
c
Copy code
return new k8s.Provider("stackKube", {
        kubeconfig: virKube.metadata.name.apply(vKN => {

            return "";
        }),
    })
@broad-dog-22463 Is there a way to make sure this apply only runs after the virKube resource has been provisioned? All I need in terms of data is the name, but I still need the output to depend on the availability of the virKube resource. I don't know how to do that. You're probably right but this is the part I'm struggling with coding.
b
in the customResource options, you should be able to specify dependsOn
c
This is a k8s provider, dunno where to specify that
Ah, I see it has custom resource options there. I'll try this.
b
sorry, I should have been clear about where customREsource options are - apologies!
c
Absolutely no problem, I'm grateful for your assistance
b
anytime!
c
Hi @broad-dog-22463; so it appears that I didn't actually solve my problem. What I ended up writing was this:
Copy code
return new k8s.Provider("stackKube", {
        kubeconfig: pulumi.all([virKube.metadata.name, ns.metadata.name]).apply(([vKn, nsN, _]) => {
            execSync("loft use vcluster " + vKn + " --print --space " + nsN + " --cluster loft-cluster --silent > /tmp/cluster.yaml")
            return "/tmp/cluster.yaml"
        }),
    }, {dependsOn: virKube})
When we spoke earlier, I somehow got the impression that the dependsOn component of the provider ended up preventing the pulumi.all(...).apply() from running until virKube was up. That is not the case, and including this in my code causes an error if the virKube has not already been created, because the output is generated during the preview automatically. How do I inject a dependency into this output so that the apply runs after it has, assuming that there are no properties of the virKube I can just grab onto to get pulumi to infer that?
b
just catching up here @clever-cartoon-41433 anything that runs inside the apply will await until the resource has been created, however, it looks like what you want to do is create a new resource with the output of a command. You will have to use a dynamic provider to build the dependency graph
c
Hi @billowy-army-68599; The problem is that the apply-contents are not being awaited by the creation of the resource, because (as I understand it) pulumi knows the values of virKube.metadata.name and ns.metadata.name before anything is actually applied. If I can find some way to make sure that actually happens, my code will work and I won't need any dynamic providers. I would give an unused property only known after creation to pulumi.all() as a hack, but in this particular case the crd virKube doesn't have any properties I can access as Outputs that aren't known at preview-time.
https://github.com/pulumi/pulumi/issues/5736 ^ It is similar to the workaround from the above thread,where he uses dvosOutput to force it as a dependency against the record, except I lack the "dvosOutput" to do something like this.