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

colossal-tailor-72573

12/28/2023, 1:35 AM
I have a perhaps silly question. I often have an array of some resource (lets call this []A) that I want to pass into another module which creates a different resource (call this B) . The B resource will take a StringArray which references some output on A as an input in one of the args. The type on the B resource creation args is declared as a StringArray. My question is -- is there a convenient way to convert the outputs from []A to the pulumi.StringArray type?
Copy code
(variable of type []pulumi.StringOutput) as pulumi.StringArrayInput value in struct literal: []pulumi.StringOutput does not implement pulumi.StringArrayInput (missing method ElementType)
c

cuddly-flower-91328

12/29/2023, 12:54 AM
pulumi.ToStringArray?
c

colossal-tailor-72573

12/29/2023, 10:23 PM
ToStringArray takes an []string not []pulumi.Output or []pulumi.StringOutput, so that's out. I ended up making a loop but don't love it. input := make(pulumi.StringArray, len(A)) for i, v := range A { input[i] = A.SomeStringOutput } resource, err := NewBResource(ctx, "some name", &BArgs{ SomeProp: input, })
3 Views