https://pulumi.com logo
#general
Title
# general
r

refined-pilot-45584

06/19/2023, 3:23 PM
Hey All, Sorry I have posted in the Go Channel but there isn’t a lot of activity there. So I thought. I would Rephrase my question and see if some one can answer more Generally 😉 … For context I am using Go. But I think my Question is more specific to Pulumi Types. When dealing with a Pulumi Type that is an “ArrayInput” object. Can we use native language concepts to “Append” or “Splice” These Arrays. A Specific Example. I am trying to Dynamically construct a collection of Load Balancer Backend Groups for Google Cloud with Pulumi in GO.
Copy code
Backends: &compute.BackendServiceBackendArray{}
Is the Struct I would like to Populate. I could simply say
Copy code
Backends: &compute.BackendServiceBackendArray{
				&compute.BackendServiceBackendArgs{
					Group: "/projects/xxxx/global/backendservice/yyyy",
				},
			},
However this is obviously not dynamic. It I wanted to build
Copy code
BackendServiceBackendArray{}
in a loop; or If I wanted to Append
Copy code
&compute.BackendServiceBackendArgs{}
into the Array. Is there a way to do this… for Example
Copy code
backend := &compute.BackendServiceBackendArray{}
backends = append(backends, &compute.BackendServiceBackendArgs{Group: "xxxxxx"})
I am looking for the correct way to dynamically build out these InputArray Objects?
b

billowy-army-68599

06/19/2023, 3:26 PM
@refined-pilot-45584 I responsed, things are slow here over the weekend. You just need to use the input type, and you can build it
r

refined-pilot-45584

06/19/2023, 3:28 PM
Cheers @billowy-army-68599 appreciate that; I Guess I was hoping some one in the community from EMEA (where I am) or APAC might have seen it on Monday morning. Appreciate the response. I am going to look into this and see if I can resolve. Thanks for your help.