fancy-spoon-7206
07/05/2022, 3:06 PM"outputs": {
"privateSubnets": [
"subnet-0ef90f8900aa4e533",
"subnet-06e84b274ae517d39",
"subnet-01465b8f34f6490ee"
],
"publicSubnets": [
"subnet-0c914a9aaec54e2a7",
"subnet-0893e2cfd9de09404",
"subnet-0216f9627f4fb20ef"
],
"vpcId": "vpc-0f0e8a3ca9c7c8b41"
},
My intention is to count the number of private/public subnets. The data type of outputs is map[string]interface{}
.
for _, res := range stack.Deployment.Resources {
privateSubnets := res.Outputs["privateSubnets"].(interface{})
log.Infoln(privateSubnets.([]string))
}
I would like to understand the type assertion to read through the values in the interface. Below is the error I get
--- FAIL: TestInfrastructure (319.75s)
panic: interface conversion: interface {} is []interface {}, not []string [recovered]
panic: interface conversion: interface {} is []interface {}, not []string
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by