-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetworkLoadBalancedFargateService: (Passed subnets are not getting picked while creating the LoadBalancer) #29812
Comments
According to this aws-cdk/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts Lines 352 to 357 in a7384c2
At this moment, the auto provisioned NLB will by default span multiple subnets based on the rule. We probably need a PR to add a new option like Before that, a workaround is to use escape hatches to override the Subnets prop of the NLB. Making this a p2, please help us prioritize by 👍 and we welcome PRs to move this forward. |
Let me add some more details: The VPC has four private subnets, with two subnets in each availability zones. When attempting to create a NetworkLoadBalancedFargateService, an error occurs, stating "A load balancer cannot be attached to multiple subnets in the same Availability Zone." This is due to the presence of two subnets in one availability zone. To address this issue, the SubnetSelection was specified for the NetworkLoadBalancedFargateService. By passing two subnets from different availability zones, the service was able to use the desired subnets(verifies in cloud formation template). However, when the Network Load Balancer was internally created by NetworkLoadBalancedFargateService, it selected all four subnets from the VPC. |
Describe the bug
var NLBService = new NetworkLoadBalancedFargateService(this, “NLBService”, new NetworkLoadBalancedFargateServiceProps {
MemoryLimitMiB = 512,
TaskDefinition = taskDefinition,
Cluster = cluster,
CircuitBreaker = new DeploymentCircuitBreaker {
Enable = true,
Rollback = true
},
ServiceName = “NLBService”,
PublicLoadBalancer = false,
TaskSubnets = new SubnetSelection {
Subnets = new [] { Subnet.FromSubnetId(this, "subnet", "subnet-12345678”9) }
}
});
This is my code subnet passed via SubnetSelection is getting passed to ECS service, but Loadbalancer picks all the subnets from VPC, and its not taking the subnets from the list which is passed in above code.
Expected Behavior
Expected behaviour is it should pick the passed subnet while creating the NetWork LoadBalancer.
Current Behavior
Passed subnets are not getting picked while creating the LoadBalancer
Reproduction Steps
Above code is producing the issue
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.134.0 (build 265d769)
Framework Version
No response
Node.js Version
v20.12.0
OS
Linux
Language
.NET
Language Version
6
Other information
No response
The text was updated successfully, but these errors were encountered: