One more question: if I have a variable with type ...
# general
g
One more question: if I have a variable with type pulumi.Input<string> can I use it in conditionals that check the actual string value somehow?
g
You’ll have to resolve the input with an Output/apply since the value might not be known otherwise. Something like:
Copy code
const foo: pulumi.Input<string> = "possibly-unknown-value"
pulumi.output(foo).apply(foo => {
  if (foo === "bar") {
     console.log("it's a bar")
  }
})
g
and I’m allowed to create new resources inside the `if (foo === …`block? Like instantiate my kubernetes.Chart resource?
g
It’s possible to create resource inside an
apply
, but can cause inaccurate previews, and isn’t recommended if you can avoid it. https://www.pulumi.com/docs/intro/concepts/programming-model/#apply
g
my usecase is: if the cluster that I’m configuring is using Ambassador as gateway (ingress), I need to remove the Ingress created by a Helm chart and add a Mapping (Ambassador CRD)
I’ll try to figure out a way to remove it, thanks!
👍 1