noobie question - How do I print an array of Pulum...
# golang
m
noobie question - How do I print an array of Pulumi types with
ctx.Export
? I've tried looping round:
Copy code
for _, subnet := range subnets {
			ctx.Export("Subnet CIDR", subnet.CidrBlock)
			ctx.Export("Subnet AZ", subnet.AvailabilityZone)
		}
But, predictably, it only prints the last element in the array
l
You can construct an export arrays (types might need some work):
Copy code
var outputArray []pulumi.StringOutput
for _, subnet := range subnets {
outputArray = append(outputArray, subnet.CidrBlock)
}
ctx.Export("CidrBlocks", outputArray)
👍 2
m
Thank you Evan, will give this a shot.
h
So I'm trying to iterate on this fine example though I'm falling short on
ctx.Export("Ipv4Address", outputArray)
I get a missing method ElementType
So if I do
ctx.Export("Ipv4Address", outputArray[1])
I get a expected outcome but how can I properly iterate through all the elements in the array to have it reflect in Pulumi's output?
l
can you share the full code sample and the full exception?
h
Hi Evan. I ended up settling on this. Unsure if this is the best implementation but it got what I was trying to achieve https://github.com/anthr76/infra/commit/6869acbc00ebe4cfd6617020e191eaf9f6fcd839#diff-035da15de753145796f6d5eb2cc[…]c119dfc32266e12b14c46c685bR1-R19
l
Great!