aws / aws/aws-cdk

NetworkLoadBalancedFargateService: (Passed subnets are not getting picked while creating the LoadBalancer)

Open
#29,812 3 comments 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs @aws-cdk/aws-ecs-patterns bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
71

Description

### 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_

Contributor guide

Open the contributing guide

Research direction

Start at the NetworkLoadBalancedFargateService construct and trace how TaskSubnets is applied to the ECS service versus the network load balancer. Reproduce the behavior from the provided .NET example with CDK 2.134.0; the fix is complete when the load balancer uses the explicitly passed subnets and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.