ambitious-salesmen-39356
05/25/2021, 4:31 PMbillowy-army-68599
ambitious-salesmen-39356
05/25/2021, 5:12 PM[]string
The example given is
publicSubnetIds := tfNetState.Outputs.ApplyT(func(args interface{}) ([]string, error) {
ids := args.(map[string]interface{})["public-subnet-ids"].([]interface{})
subnetIds := make([]string, len(ids))
for i, v := range ids {
subnetIds[i] = v.(string)
}
return subnetIds, nil
}).(pulumi.StringArrayOutput)
for _, v := range publicSubnetIds {
fmt.Printf("id: %s", v)
}
?
But apparently this object isn't iterablebillowy-army-68599
publicSubnetIds
is still async, so it's not known - it's not iterable because it's not known how long it is:
what are you trying to pass the public subnets to?ambitious-salesmen-39356
05/25/2021, 5:28 PMbillowy-army-68599
publicSubnetIds := tfNetState.Outputs.ApplyT(func(args interface{}) ([]string, error) {
// you can print each value here, because the value is resolved
fmt.Println(id)
}).(pulumi.StringArrayOutput)
var awsPublicSubnets []ec2.Subnet
publicSubnetIds := tfNetState.Outputs.ApplyT(func(args interface{}) ([]string, error) {
// do an append inside the apply
}).(pulumi.StringArrayOutput)
ambitious-salesmen-39356
05/25/2021, 5:33 PM