This message was deleted.
# general
s
This message was deleted.
b
you'll need to use reflection and an apply to access the raw value. If you're willing to share some code, we might be able to help
s
@billowy-army-68599 Golang
Copy code
Ec2_server, err = ec2.NewInstance(ctx, "fooInstance", &ec2.InstanceArgs{
			Ami:          pulumi.String("ami-005e54dee72cc1d00"),})

Ec2_server.ID() // this gives IDOutput type but I want this as string/*string.
l
Where are you using that ID? If you're passing it to more Pulumi code, you can pass the output, you don't need the string. If you need the string version for something else, you have to use an ApplyT function, iirc.
w
If you just need to convert
IDOutput
to
StringOutput
you can use
.ToStringOutput()
https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v2@v2.23.2/go/pulumi#IDOutput.ToStringOutput
s
@little-cartoon-10569 @white-balloon-205 can you tell how to convert to string/*string in golang using applyT you are saying. I can’t figure that out new to pulumi as well as to golang.
@little-cartoon-10569 I am passing it to LookupInstance function which expects *string/string ID.
w
I am passing it to LookupInstance function which expects *string/string ID.
You will need to call
LookupInstance
from inside the
.ApplyT
callback. Schematically
idoutput.ApplyT(func (id pulumi.ID) { return ec2.LookupInstance(... id ...).Ami })
.
160 Views