I am stuck trying to use iterated list of subnets to create subnet_ids for transit gateway. The subnets are created via zoneIterator which has a list of availability zones. How do I make this work using escape hatches?
const tgwSubnets = new Subnet(this, "tgw-subnets", {
forEach: zoneIterator,
vpcId: this.vpc.id,
cidrBlock: Fn.cidrsubnet(this.vpc.cidrBlock, 8, Fn.lengthOf(zones.names) + Fn.index(zones.names, zoneIterator.value)),
availabilityZone: zoneIterator.value,
});
const tgwRt = new RouteTableAssociation(this, "tgw-rta", {
subnetId: "${each.value.id}",
routeTableId: this.tgwRouteTable.id,
});
tgwRt.addOverride("for_each", `\${aws_subnet.${tgwSubnets.friendlyUniqueId}}`); //Is this correct way to iterate?
const tgwAttachment = new Ec2TransitGatewayVpcAttachment(
this,
"firewall-vpc-attachment",
{
vpcId: this.vpc.id,
subnetIds: [],
transitGatewayId: "XXXX",
transitGatewayDefaultRouteTableAssociation: false,
transitGatewayDefaultRouteTablePropagation: false,
applianceModeSupport: "enable",
}
);
tgwAttachment.addOverride("subnet_ids",`\${aws_subnet.tgw-subnets[*].id}`) //Need to pass in the list of subnet ids
I get this error.