How do I compare `Output<string>` with `stri...
# general
c
How do I compare
Output<string>
with
string
? Here is the example
Copy code
const clusterName = xyz
                .getOutput('cluster')
                .apply(cluster => cluster.ClusterName) as Output<string>;
The code has to compare the
clusterName
. I have tried with something like this and it failed.
Copy code
switch (clusterName) {
            case Output.create('alpha'):{
w
To first approximation - you have to do the switch inside the
apply
. That is - the actual string value of the output is only known when the callback passed to apply is called - and so anything you want to do with that value must be done inside that callback. During previews, some Outputs will never be known (the resource hasn't been constructed yet), and during updates, these values may not be known until after the resource is actually created in the resource provider. In your sepcific cases - two things: 1. If you share a larger snippet of what you want to do, it may be more clear how your switch is getting used, and how it can be done inside an apply) 2. I think
xyz
is a
StackReference
? If so, we recently added
.getOutputSync()
which will get a normal
string
instead of `Output<string`>. This should generally make this specific case easier. This is possible because StackReference results really are always known (assuming the stack exists at all).