sparse-intern-71089
06/24/2020, 1:26 AMsalmon-account-74572
06/24/2020, 1:27 AM// Create public subnets in the VPC
pubSubnetIds := make([]string, numOfAZs)
for idx := 0; idx < numOfAZs; idx++ {
subnetAddr := (idx)*16
subnetCidrBlock := fmt.Sprintf("%s.%d.0/23", vpcNetPrefix, subnetAddr)
subnetArgs := &ec2.SubnetArgs {
VpcId: vpc.ID(),
AvailabilityZone: pulumi.String(azNames[idx]),
CidrBlock: pulumi.String(subnetCidrBlock),
MapPublicIpOnLaunch: pulumi.Bool(true),
}
subnet, err := ec2.NewSubnet(ctx, fmt.Sprintf("%s-pub-subnet-%d", baseName, idx), subnetArgs)
if err != nil {
log.Printf("error creating subnet: %s", err.Error())
}
pubSubnetIds = append(pubSubnetIds, subnet.Id)
}
salmon-account-74572
06/24/2020, 1:29 AMsubnet
variable doesn't have any field named Id
, id
, or any variation I've tried so far. The .ID()
method that is used for VPCs doesn't seem to work for subnets. So how does one capture the ID for a subnet that you've created?gentle-diamond-70147
06/24/2020, 1:42 AM.ID()
should work. Are you getting an error when trying it?salmon-account-74572
06/24/2020, 2:03 AMappend
statement (due to a type mismatch, as far as I can tell). Using pulumi.String
doesn't help.gentle-diamond-70147
06/24/2020, 3:57 AMpubSubnetIds := make([]pulumi.IDOutput, numOfAZs)
salmon-account-74572
06/24/2020, 11:31 AMsalmon-account-74572
06/24/2020, 11:31 AM