breezy-painter-29573
03/28/2022, 3:01 AMfor i, az in enumerate(azs):
subnet = aws.ec2.Subnet(
resource_name=f"public-{i}",
vpc_id=vpc.id,
availability_zone=az,
cidr_block=vpc.cidr_block.apply(lambda cidr_block: ip_network(cidr_block).subnets(new_prefix=27)[i]),
tags=tags,
)
subnets.append(subnet)
but it fails with the TypeError: 'generator' object is not subscriptable
. Which, probably makes sense. I just can’t find a way to do it in a for loop.
Thank you in advance!
P.S. ip_network
is a function for netaddr
.modern-evening-83482
07/08/2022, 5:35 AMprivate_subnets = []
for subnet in range(1, number_of_azs + 1):
ec2_subnet = aws.ec2.Subnet(
f"{env}-ec2Subnet-{subnet}-{suffix}",
availability_zone=available_azs.names[subnet - 1],
cidr_block=f"10.27.{subnet}.0/24",
vpc_id=vpc.id,
map_public_ip_on_launch=False,
tags={
"Type": "Private",
"Name": f"{env}-ec2Subnet-{subnet}-private-{suffix}",
},
opts=pulumi.ResourceOptions(provider=provider),
)
private_subnets.append(ec2_subnet)
will this work? I need to get the subnet ids at the end..However I am still getting each element as type Output...