Open fshields opened 4 years ago
While continuing to troubleshoot this, I discovered that it may be related to #3126
Hitting the same issue here, and the one_per_az
argument to SubnetSelection
doesn't seem to work either.
Workaround
const albFargetService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
...
});
const cfnLoadBalancer = albFargetService.loadBalancer.node.defaultChild as CfnLoadBalancer
cfnLoadBalancer.subnets = vpc.selectSubnets({ onePerAz: true, subnetType: SubnetType.PUBLIC}).subnetIds
Are there any updates on this? Just ran into this in python, and I can't seem to override the subnets after creation like in the posted TypeScript workaround
The following python work-around uses two approaches. The approach above and a subnet_ids approach. Use it depending on what you have available.
subnet_ids = ['subnet-1234', 'subnet-5678']
alb_fargate_service = ecs_patterns.ApplicationLoadBalancedFargateService(self, .....)
cfn_lb = alb_fargate_service.load_balancer.node.default_child
if not subnet_ids:
cfn_lb.subnets = vpc.select_subnets(subnet_group_name=subnet_group_name, availability_zones=availability_zones, one_per_az=True).subnet_ids
else:
cfn_lb.subnets = subnet_ids
with CDK (lib/cli) 2.22 the issue can't be solved with
cfnLoadBalancer.subnets = vpc.selectSubnets({ onePerAz: true, subnetType: ec2.SubnetType.PUBLIC }).subnetIds
because onePerAz
does not what it says, leading to CreateService error: subnets can have at most 16 items.
the fix from @nkolatsis also doesn't fix it for me :(
Any plans to fix this? It's been open for 3 years.
The ApplicationLoadBalancedFargateService construct (and possibly other related constructs) fails to deploy when there exist multiple public subnets in the same AZ. It appears that the construct selects all public subnets from the provided VPC by default.
Reproduction Steps
I was following the "ECS Example" described at https://docs.aws.amazon.com/cdk/latest/guide/ecs_example.html but utilizing an existing VPC (with 7 pre-existing public subnets) instead of creating a new VPC like the example prescribes.
Error Log
Environment
Other
This is :bug: Bug Report