https://pulumi.com logo
#general
Title
# general
g

gray-city-50684

03/03/2020, 4:45 PM
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

gorgeous-egg-16927

03/03/2020, 4:47 PM
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

gray-city-50684

03/03/2020, 4:50 PM
and I’m allowed to create new resources inside the `if (foo === …`block? Like instantiate my kubernetes.Chart resource?
g

gorgeous-egg-16927

03/03/2020, 4:54 PM
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

gray-city-50684

03/03/2020, 4:55 PM
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