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

many-agent-57485

05/26/2021, 12:53 PM
Hi, I've tried to read the docs, but couldn't understand . How do i convert
pulumi.StringOutput
to
string
or
pulumi.String
? thanks !
b

bored-table-20691

05/26/2021, 3:09 PM
To get to the underlying string you can use ApplyT which will also return a StringOutput. But more generally, what are you trying to achieve?
a

ambitious-salesmen-39356

05/26/2021, 3:19 PM
I found this quite confusing as well. My reason was basically I'm coming from Terraform and I'm accustomed to doing stuff like interpolating strings into IAM policies and it being extremely straightforward, since TF abstracts the hard work for you
m

many-agent-57485

05/26/2021, 3:21 PM
@bored-table-20691 well, i've already found workaround. But the usecase was to create route53 entry for other created resources (like rds).
b

bored-table-20691

05/26/2021, 3:42 PM
You’d typically use either ApplyT or pulumi.Sprintf - depending on how sophisticated the construction of the new value needs to be.
b

billowy-army-68599

05/26/2021, 3:45 PM
@many-agent-57485 @ambitious-salesmen-39356 if you're trying to wrap your head around why you can't manipulate these values without
ApplyT
- give this a read: https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html
a

ambitious-salesmen-39356

05/26/2021, 3:46 PM
Good to know I'm not the only person who didn't find this obvious 😅
b

billowy-army-68599

05/26/2021, 3:48 PM
it's a very common question, and I struggled with it myself 🙂
a

ambitious-salesmen-39356

05/26/2021, 3:52 PM
Good article, that does indeed help. Thanks!
it's a concept I've always I guess inherently understood in terms of values only known after apply and their being used to construct the DAG, they're just not quite as straightforward to work with (at least in Go) relative to their tf equivalents, ie my point of reference
b

billowy-army-68599

05/26/2021, 3:58 PM
i totally hear you, we continue to try make this easier as time goes on
m

mammoth-honey-6147

08/13/2021, 8:25 AM
Coming from Terraform myself I also found
.Apply
difficult to wrap my head around. The aforementioned blog post from @billowy-army-68599 is awesome and after a while it makes sense, just took some practice
3 Views