sparse-intern-71089
12/12/2022, 8:59 PMgifted-fall-44000
12/12/2022, 9:02 PMStringOutput.ApplyT(func(myString string) error {
// use Output as string here
return nil
})
gifted-fall-44000
12/12/2022, 9:02 PMctx.Export() though.
flaky-school-70251
12/12/2022, 9:02 PMStringInput
, edited my original message.gifted-fall-44000
12/12/2022, 9:03 PMStringInput.ToStringOutput.ApplyT
flaky-school-70251
12/12/2022, 9:04 PMStringOutput
gifted-fall-44000
12/12/2022, 9:04 PMstring(StringInput) should work fine.
flaky-school-70251
12/12/2022, 9:04 PMflaky-school-70251
12/12/2022, 9:04 PMcannot convert nodeId (variable of type pulumi.StringInput) to type string
gifted-fall-44000
12/12/2022, 9:06 PMflaky-school-70251
12/12/2022, 9:07 PMgifted-fall-44000
12/12/2022, 9:07 PMflaky-school-70251
12/12/2022, 9:07 PMnodeId := instance.ID().ToStringOutput().ApplyT(func(id string) string {
return id
}).(pulumi.StringOutput)
flaky-school-70251
12/12/2022, 9:08 PMgifted-fall-44000
12/12/2022, 9:08 PMflaky-school-70251
12/12/2022, 9:12 PMStringInput
and inside there I need to convert it to a regular stringfierce-ability-58936
12/12/2022, 9:13 PMgifted-fall-44000
12/12/2022, 9:15 PMflaky-school-70251
12/12/2022, 9:17 PMfmt.Printf
or fmt.Sprintf
with a pulumi.Output
I get output like
{%!s(*pulumi.OutputState=&{{0 0} 0xc000513a40 0xc0005ce258 0 <nil> <nil> false false 0x11e1ee0 [0xc0005ce500]})}
gifted-fall-44000
12/12/2022, 9:17 PMfierce-ability-58936
12/12/2022, 9:17 PMpulumi.Sprintf
! It takes inputs and you get an output.gifted-fall-44000
12/12/2022, 9:18 PMgifted-fall-44000
12/12/2022, 9:19 PMflaky-school-70251
12/12/2022, 9:19 PMpulumi.Sprintf
also creates a pulumi.StringOutput
not a string
cannot use pulumi.Sprintf("%s", NodeId) (value of type pulumi.StringOutput) as type string in argument
fierce-ability-58936
12/12/2022, 9:21 PMgifted-fall-44000
12/12/2022, 9:21 PMsubnet.CidrBlock.ApplyT(func(cidr string){
fmt.Printf("%s", cidr)
})
gifted-fall-44000
12/12/2022, 9:22 PMgifted-fall-44000
12/12/2022, 9:22 PMflaky-school-70251
12/12/2022, 9:22 PMflaky-school-70251
12/12/2022, 9:23 PMflaky-school-70251
12/12/2022, 9:23 PMgifted-fall-44000
12/12/2022, 9:24 PMflaky-school-70251
12/12/2022, 9:25 PMpulumi.StringOutput
, somewhere in the middle it is passed as a pulumi.StringInput
, then it needs to become a string
for another step to then be printed out to the console in the last steapflaky-school-70251
12/12/2022, 9:25 PMflaky-school-70251
12/12/2022, 9:25 PMflaky-school-70251
12/12/2022, 9:29 PMflaky-school-70251
12/12/2022, 9:29 PMpanic: applier must return exactly one or two values
goroutine 1 [running]:
flaky-school-70251
12/12/2022, 9:30 PMApplyT
should return something??gifted-fall-44000
12/12/2022, 9:30 PMgifted-fall-44000
12/12/2022, 9:30 PMvar myString string
_ := subnet.CidrBlock.ApplyT(func(cidr string){
myString = fmt.Sprintf("%s", cidr)
})
fmt.Printf("%s", myString)
gifted-fall-44000
12/12/2022, 9:31 PMflaky-school-70251
12/12/2022, 9:32 PMflaky-school-70251
12/12/2022, 9:32 PMApplyT
I can't test it with a pulumi preview
flaky-school-70251
12/12/2022, 9:33 PMgifted-fall-44000
12/12/2022, 9:33 PMflaky-school-70251
12/12/2022, 9:39 PMpulumi up
and my code is
var strNodeId string
nodeId.ToStringOutput().ApplyT(func (nodeId string) error {
fmt.Printf("Node ID is: %s\n", nodeId)
strNodeId = fmt.Sprintf("%s", nodeId)
return nil
})
fmt.Printf("and strNodeId is: %s\n", strNodeId)
but the output is
and strNodeId is:
and strNodeId is:
and strNodeId is:
Node ID is: 062653f3-4369-466a-83a3-c48537c81449
Node ID is: 88f93e13-75ba-470a-b51e-00ba8ebe1bd8
Node ID is: 6e390b51-d7ba-447b-a0c3-7c6ed22d0993
flaky-school-70251
12/12/2022, 9:40 PMstrNodeId
is not being populated properly when passed down the stackgifted-fall-44000
12/12/2022, 9:51 PMfierce-ability-58936
12/12/2022, 9:52 PMfmt.Printf("Node ID is: %s\n", nodeId)
You can use ctx.Export("var", strNodeId - when previewing, it'll have unresolved value, which will resolve after up
is finished.flaky-school-70251
12/12/2022, 9:54 PMfierce-ability-58936
12/12/2022, 9:55 PMgifted-fall-44000
12/12/2022, 9:55 PMflaky-school-70251
12/12/2022, 9:56 PMgifted-fall-44000
12/12/2022, 9:56 PMgifted-fall-44000
12/12/2022, 9:56 PMflaky-school-70251
12/12/2022, 9:56 PMgifted-fall-44000
12/12/2022, 9:57 PMflaky-school-70251
12/12/2022, 9:58 PMstrNodeId
is empty when creating the other resourcegifted-fall-44000
12/12/2022, 9:58 PMoutput := pulumi.Sprintf("%s: %s", nodeId, <some other details I want to display>)
ctx.Export("My NodeID and Other Stuff:", output)
fierce-ability-58936
12/12/2022, 9:58 PMflaky-school-70251
12/12/2022, 9:59 PMflaky-school-70251
12/12/2022, 9:59 PMgifted-fall-44000
12/12/2022, 10:00 PMfierce-ability-58936
12/12/2022, 10:00 PMflaky-school-70251
12/12/2022, 10:00 PMfierce-ability-58936
12/12/2022, 10:00 PMgifted-fall-44000
12/12/2022, 10:01 PMgifted-fall-44000
12/12/2022, 10:02 PMgifted-fall-44000
12/12/2022, 10:03 PMfierce-ability-58936
12/12/2022, 10:11 PMflaky-school-70251
12/12/2022, 10:26 PMflaky-school-70251
12/12/2022, 10:26 PMflaky-school-70251
12/12/2022, 10:26 PMflaky-school-70251
12/12/2022, 10:26 PM