aws / aws/aws-cdk

[ecs-patterns]: allow use of existing load balancer in ApplicationMultipleTargetGroupsEc2Service

Open
#11,347 6 comments 9 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs-patterns effort/medium feature-request feature/pattern p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

## This is a :rocket: Feature Request

### Description

Would like to be able to use an existing load balancer with ApplicationMultipleTargetGroupsEc2Service.

Load balancer pricing includes a fee per hour of load balancer running, which currently means about $18 per month. Running many services, each with its own balancer, can quickly add up.

Additionally, creating a separate load balancer for each service means we can't run multiple services under the same DNS name. So it's not possible to call different microservices depending on the path, for example (probably a common pattern?). Or group multiple subdomains on the same load balancer.

### Use Case

```
const service1 = new ApplicationMultipleTargetGroupsEc2Service(this, "Service1",{
...
targetGroups: [
{
containerPort: 80,
listener: "listener",
**pathPattern: "service1",**
priority: 1,
protocol: Protocol.TCP,
},
});
const service2 = new ApplicationMultipleTargetGroupsEc2Service(this, "Service2",{
targetGroups: [
{
containerPort: 80,
listener: "listener",
**pathPattern: "service2",**
priority: 2,
protocol: Protocol.TCP,
},
});
```

I would like that that two gets deployed to (Use the same LoadBalancer, instead of creating one for Each Service):
- myalb.amazonaws.com/service1
- myalb.amazonaws.com/service2

### Proposed Solution

Not have a workaround. Would need to skip ECS Patterns for this.

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

Contributor guide

Open the contributing guide

Research direction

Start at the ecs-patterns implementation of ApplicationMultipleTargetGroupsEc2Service and inspect how it creates its load balancer, listeners, and target groups. Review the related tests, if present, before determining how an existing load balancer and listener could be supplied. Done means multiple services can share one load balancer with distinct path patterns, priorities, and target groups, covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.