How does one append or add new items to a custom P...
# golang
r
How does one append or add new items to a custom Pulumi Array Type? For example if I have a Group of Network Endpoint Backends and I want to keep adding multiple NEGs to a Group. I can’t use “append” as it says append will only work with a Slice, naturally.
b
@refined-pilot-45584 you need to use the
BackendArrayInput{}
type, which will allow you to append to an array:
Copy code
var iTypes = pulumi.StringArray{}
iTypes = append(iTypes, pulumi.String("t3.medium"))
r
Thanks for the pointer again; I must admit I feel kind of stupid on this one. But I am not certain I follow the approach. I am attempting to solve in the following way.
Copy code
var BackendServiceBackendArray = &compute.BackendServiceBackendArray{}
		// LOOP START
			// DYNAMIC STUFF Create new Array Item

			newItem := &compute.BackendServiceBackendArrayInput{
				&compute.BackendServiceBackendArgs{ 
					// CONTENT
				},
			}

			// Append Item to Existing Array
			BackendServiceBackendArray = append(BackendServiceBackendArray, NewItem)
		// END LOOP
I am not 100% sure if I am using the BackendArrayInput type in the correct location here;
b
can you share your full code, so I can recreate and fix?
r
I can. Standby.