I have a perhaps silly question. I often have an ...
# golang
c
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
pulumi.ToStringArray?
c
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, })