Hi everyone, how can I make a Pulumi Resource depe...
# typescript
m
Hi everyone, how can I make a Pulumi Resource depend on a "data source" from a terraform provider. I am using talos terraform bridge with Pulumi.
export const healthCheck = talosClientConfig.clientConfiguration.apply(clientConfiguration =>
talos.getClusterHealth({
endpoints: [CONTROLPLANE_IP],
controlPlaneNodes: [CONTROLPLANE_IP],
workerNodes: WORKER_IPS,
clientConfiguration: clientConfiguration,
})
);
const cilium = healthCheck.apply(healthCheck => new k8s.helm.v3.Chart("cilium", {
chart: "cilium",
version: "1.15.6",
namespace: "kube-system",
fetchOpts: {
repo: "<https://helm.cilium.io/>",
},
values: {
ipam: {
mode: "kubernetes",
},
kubeProxyReplacement: false,
securityContext: {
capabilities: {
ciliumAgent: [
"CHOWN",
"KILL",
"NET_ADMIN",
"NET_RAW",
"IPC_LOCK",
"SYS_ADMIN",
"SYS_RESOURCE",
"DAC_OVERRIDE",
"FOWNER",
"SETGID",
"SETUID",
],
cleanCiliumState: [
"NET_ADMIN",
"SYS_ADMIN",
"SYS_RESOURCE",
],
},
},
cgroup: {
autoMount: {
enabled: false,
},
hostRoot: "/sys/fs/cgroup",
},
}
}));
I cannot use healthCheck in dependsOn I get typescript error and .apply() doesn't show in preview. What is the correct approach? Thanks in advance.
s
Hi @most-kilobyte-1525 if your code references any outputs from that terraform provider (as in, passing a value to another resource), then the dependency is automatic and implicit. The Pulumi Engine will detect this automatically and act accordingly. If you need to explicitly set a dependency between 2 resources that do not share referenced values, then look at the resource option
dependsOn
(doc). Reading your code, this is what you should be using to set dependencies between the healthCheck and the Chart. Finally, in your example above, you should not create a resource within a
.apply()
- This is a will known anti-pattern which might leads to problems and confusion later on.
m
Thanks for the reply. I know this, healthCheck is not a resource tho its a function. It calls a terraform data source. I can't use dependsOn
There are no docs for terraform bridge?