Hi, super nooby question. I need to access the ra...
# golang
b
Hi, super nooby question. I need to access the raw string value of a StringOutput to interpolate it into another string. The
Apply
function doesn't return a raw string. how can I do this? Small go snippet would be awesome.
oh I see, you can't ever get a handle on the string value in the top level scope unless you assign to a variable inside of the
Apply
function. Apply is mostly just used to transform `pulumi.StringOutput`s
b
You have to do in an async way. One way is to use a wait group and assign the inner apply value to an outside variable.
Copy code
var str string
var wg sync.WaitGroup
wg.Add(1)
myPulumiOutput.ApplyT(func(s string) error {
  defer wg.Done()
  str = s
  return nil
})
wg.Wait()
It's from my phone so expect lots of errors, but that's the general idea
b
makes sense @brash-match-91530! thanks 🙂
@brash-match-91530 I'm actually not sure that would work, because Pulumi runs all your code first to create the DAG of resource dependencies. This would block that I think. @billowy-army-68599 am I correct?
e
@numerous-printer-41511 were you able to figure this out?