https://pulumi.com logo
#golang
Title
# golang
b

bright-sandwich-93783

06/29/2021, 7:33 PM
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

brash-match-91530

06/30/2021, 1:54 PM
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

bright-sandwich-93783

06/30/2021, 11:03 PM
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

eager-vase-43200

10/05/2021, 12:46 AM
@numerous-printer-41511 were you able to figure this out?
3 Views